```
def isHappy(self, n):
"""
:type n: int
:rtype: bool
"""
d = set()
def inner(n):
if n < 1 or n in d:
return False
if n == 1:
return True
su = 0
w = n
while n:
su += (n % 10) ** 2
n = int(n / 10)
d.add(w)
return inner(su)
return inner(n)
```