import math
def isKaprekar(a):
n = (int)(math.pow(a, 2))
n_arr = [int(i) for i in str(n)]
midd = 0
# take care of the numbers lt 10:
if a == 1:
return True
if n < 10:
return False
if n % 2 == 0:
midd = (int)(len(n_arr) / 2)
else:
midd = (int)(len(n_arr) / 2)
if( (int)(''.join(str(x) for x in n_arr[0:midd])) +
(int)(''.join(str(x) for x in n_arr[midd :])) == a):
return True
else:
return False
for i in range(0, 10001):
# print(i)
if isKaprekar(i):
print(i)
PiTong