Among the integer less than 10, only 1 and 7 are happy number.

```
bool isHappy(int n) {
if (n == 1 || n == 7) return true;
if (n < 10) return false;
int sum = 0;
while (n) {
sum += (n % 10) * (n % 10);
n /= 10;
}
return isHappy(sum);
}
```