You have surely already learned that by adding up the digits of an integer n and repeating the process with the result obtained, you would eventually get the remainder from dividing n by 9. For example, with 1,789, we find 1 + 7 + 8 + 9 = 25, then 25 gives 2 + 5 = 7. Furthermore, 1,789 = 198 × 9 + 7. What happens if we tweak the rules of the game slightly and add the squares of the digits instead?

There's joy

Let's go back to our first example to properly understand the new rules of the game. This time, the integer 1,789 gives 12 + 72 + 82 + 92 = 195. Then we start again: 195 gives 12 + 92 + 52 = 107. We're off to a good start; let's see what comes next: 107 gives 50, then 25, 29, 85, 89, 145, 42, 20, 4, 16… All this seems quite erratic. And yet, with a little perseverance, we find 37, 58, and then 89 right after. We had already come across this integer, so we now know that we will never leave this cycle of length 8: 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58.
Of course, the temptation to try a new number is strong! Let's go with 2,026. This integer gives: 44 → 32 → 13 → 10 → 1. We can consider the process to stop here, since the integer 1 gives 1 again. So there are at least two possible outcomes: ending up at 1, or ending up in the cycle of eight integers we already encountered — or, equivalently, ending up at 4. Integers that end up at 1 are called happy numbers. Their study in all likelihood began in an article in The American Mathematical Monthly dated 1945. Its author, Arthur Porges, was at the time an instructor at a military base. This mathematics professor at the Illinois Institute of Technology would become known to the general public a few years later for a prolific output of science-fiction stories and detective short stories with particularly intricate plots.