Advertisement
Guest User

fsdfdsfsdfdsf

a guest
Nov 18th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. def square_digit_chain(n):
  2. n = str(n)
  3. new_n = 0
  4. while n != '89' and n != '1':
  5. new_n = 0
  6. for digit in n:
  7. new_n += int(digit)**2
  8. n = str(new_n)
  9. return n
  10.  
  11. def count_nums_1(limit):
  12. count_1 = 0
  13. for number in range(1, limit):
  14. if square_digit_chain(number) == '89':
  15. count_1 += 1
  16. return count_1
  17.  
  18. print(count_nums_1(10000000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement