```
def isHappy(self, n):
while n > 4:
res = 0
while n:
res = res + (n % 10)**2
n /= 10
n = res
return n == 1
```

We can make it more simple, but it takes 4ms langer than the method above

```
def isHappy(self, n):
res = 0
while n:
res = res + (n % 10)**2
n /= 10
n = res
return self.isHappy(n) if n > 4 else n ==1
```