LeetCode Solutions/Hash Table/Happy Number/Happy Number.java
<gh_stars>0class Solution {
    public boolean isHappy(int n) {
        int i = 0;
        while (n != 1 && i < 50){
            int x = 0;
            while (n != 0){
                x += Math.pow((n%10), 2);
                n /= 10;
                i++;
            }
            n = x;
        }
        return n == 1;
    }
}