Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from math import ceil

def isKaprekar(n):
  square = str(n**2)
  right = ceil(len(square)/2)
  return int(square[right*-1:]) + int(square[:len(square)-right]) == n

print("The first ten Kaprekar numbers are:")
count = 0
n = 4
while count < 10:
  if isKaprekar(n):
    print(n)
    count += 1
  n += 1