public class Solution { public boolean isHappy(int n) { int sum=0; if(n==1||n==7) return true; else if(n>1&&n<9) return false; while(n>0){ sum+=(n%10)*(n%10); n/=10; } return isHappy(sum); } }