Advertisement
stiansjogren

Untitled

Sep 5th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. def digit_sum(n):
  2. return sum(int(x) for x in str(n))
  3.  
  4. j=100
  5. k=1
  6. res = []
  7. while j<1000:
  8. k=1
  9. x = digit_sum(j)
  10. while j >= x**k:
  11. k+=1
  12. if j == x**k:
  13. res.append(j**k)
  14. j+=1
  15.  
  16.  
  17. print res
  18. print digit_sum(512)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement