publicbooleanisHappy(int n){ HashSet<Integer> set = new HashSet<>(); while (true) { int result = 0; int temp; while (n > 0) { temp = n % 10; result = result + temp * temp; n /= 10; } if (result == 1) returntrue; if (set.contains(result)) { returnfalse; }else { set.add(result); n = result; } } }