A number is happy when repeatedly replacing it with the sum of the squares of its digits eventually reaches 1.
1
A number that loops forever is not happy.
n = 19
true
Why
1² + 9² = 82 → 68 → 100 → 1
n = 2
false
1 <= n <= 2^31 - 1
Topics
Implement isHappy in the editor and return the answer — printing it is never graded.
isHappy
Problem 40 of 1146 in the arena