Write a script to find "Happy Numbers"
Peter Kim Frank Feb 5
These challenge posts have been a lot of fun. Another one inspired by Fermat's Library.
In the language of your choice, write a script to find "Happy Numbers." Via Wikipedia:
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits in base-ten, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers).
Looking at the picture in the embedded tweet will probably help solidify the process. Here are the first few happy numbers to help check your work:
1, 7, 10, 13, 19, 23, 28, 31