Problem statement
A number is happy when the sum of the squares of its digits, repeated on its own result, eventually reaches 1.
Some numbers reach 1 and some fall into a loop. Return true only for the ones that arrive.
Examples
Input19
Outputtrue
19 gives 82, then 68, then 100, then 1.
Input2
Outputfalse
The chain returns to 4 and circles without ever reaching 1.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing