```
def isHappy(self, n):
"""
:type n: int
:rtype: bool
"""
if n == 1:
return True
seen = set()
while n not in seen:
seen.add(n)
n = self.calculate(n)
if n == 1:
return True
else:
return False
def calculate(self, num):
ret = 0
while num:
ret += (num%10)**2
num = num//10
return ret
```