Happy Numbers – by hand and programming

Thanks to nrich for the following puzzle:

Have you met Happy Numbers? Start with any number you like and form a sequence by writing down the sum of the squares of the digits of each number to get the next number in the sequence. For example, from 31 you go to 10 because 3 squared plus 1 squared makes 10. Here is a ‘happy’ sequence:

31 -> 10 -> 1 -> 1 -> 1 … Smiley Face

Numbers are called ‘happy’ when their sequences, sooner or later, give repeated 1’s. We say 1 is a fixed point.

25 -> 29 -> 85 -> 89 -> 145 -> 42 -> 20 -> 4 -> 16 -> 37 -> 58 -> 89 ->…

The number 25 is sad because, however long we go on with the sequence, it will never come to 1, it will just keep repeating the terms (89, 145, 42, 20, 4, 16, 37, 58) over and over again. We call this an 8-cycle or loop. Can you find some more happy numbers?

Can you use excel or python to find more?