```
class Solution(object):
def isHappy(self, n):
if n == 1:
return True;
elif n == 4:
return False;
return self.isHappy(sumDigitSquares(n));
def leastSignificantDigit(num):
return num % 10;
def hasDigitsRemaining(num):
return (num // 10) != 0;
def sumDigitSquares(num):
sum = 0;
while hasDigitsRemaining(num):
sum += leastSignificantDigit(num)**2
num //= 10;
sum += num**2
return sum;
```