Guest User

Untitled

a guest
Jan 11th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. cpdef PowerSumGraph(int a, int s, int n):
  2. cdef int i,j,r,t
  3. G=Graph({})
  4. for i in range(1,a):
  5. r=i**(1/n)
  6. for j in range(r,s):
  7. t=j**n-i
  8. if t>0 and i<>t:
  9. G.add_edge(i,t)
  10. return G.is_connected()
  11.  
  12. sage: PowerSumGraph(13,6,2)
  13. True
  14. sage: PowerSumGraph(108,7,3)
  15. True
  16. sage: PowerSumGraph(2008,9,4)
  17. True
  18. sage: PowerSumGraph(49355,11,5)
  19. True
  20.  
  21. sage: PowerSumGraph(1500000,13,6)
  22. True
Add Comment
Please, Sign In to add comment