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

}