fork download
  1. def is_kaprekar(number):
  2. if number % 10 == 0: return False
  3. sqd_num = str(number**2)
  4. for i in range(len(sqd_num)-1):
  5. if int(sqd_num[:i+1])+int(sqd_num[i+1:]) == number: return True
  6.  
  7. for i in range(2, 9000):
  8. if is_kaprekar(i): print(i)
Success #stdin #stdout 0.04s 9992KB
stdin
Standard input is empty
stdout
9
45
55
99
297
703
999
2223
2728
4879
5292
7272
7777