Replace n by sum of squares of digits. Happy if you reach 1. Detect cycles with a set (or Floyd).
Input
19
Output
true
2
false