Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

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

Hi,

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.