# A magic number is a number that repeated the sum of its digits
# till we get a single digit is equal to 1
# 1729 = 1 + 7 + 2 + 9 = 19
# 19 = 1 + 9 = 10
# 10 = 1 + 0 = 1
import math
num = 1729
digitCount = int(math.log10(num)) + 1
sumOfDigits = 0
temp = num
while (digitCount > 1):
sumOfDigits = 0
while (temp > 0):
sumOfDigits += temp % 10
temp = temp // 10
temp = sumOfDigits
print(sumOfDigits)
digitCount = int(math.log10(sumOfDigits)) + 1
if (sumOfDigits == 1):
print("Magic number")
else:
print("Not a magic number")
'''
run:
19
10
1
Magic number
'''