public boolean isHappy(int n) {

```
int result = n;
while(result > 10){
result = 0;
while(n > 0){
int i = n % 10;
n = n/10;
result += Math.pow(i,2);
}
n = result;
} //this while loop calculates the input number and make it to a number less than and equal to 10
```

// The happy numbers less than and equal to 10 are 1,7,10

```
if(n == 7) return true;
if(n == 10) return true;
if(result == 1) return true;
return false;
}
```