```
public boolean isHappy(int n) {
int temp = 0;
while (n >= 10) {
temp += Math.pow(n % 10, 2);
n /= 10;
}
temp += Math.pow(n % 10, 2);
if (temp >= 10) {
return isHappy(temp);
} else {
if (temp == 1) {
return true;
} else {
return false;
}
}
}
```