def isHappy(self, n):
while n >=10:
s = 0
str_n = str(n)
for num in str_n:
num = int(num)
nn = num*num
s += nn
n = s
return n== 1 or n == 7
Does your solution related to some mathematical theorem?
Not really. It's kinda like empirical since the happy number less than 10 are 1 and 7.
Are you sure that the cycle-process dont exist the number less than 10?
It might be 45 kinds of two digit and more 120 kinds of three digit to prove this.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.