Published October 1997,February 2011.
In this, the third of these articles on Whole Number Dynamics , we shall complete the solution to the problem started in the first article . The later articles in this series will deal with other problems with the same theme.
Let us remind ourselves of the problem. Starting with any whole number between 1 and 999 inclusive, we add the squares of the digits; for example starting with 537 we get the number $83 (= 5^2 + 3^2 + 7^2)$. The problem was to understand what happens if we repeat the process indefinitely, and you should have seen that whatever number you started with, the list of numbers you get either ends up with the consecutive numbers $$1, 1, 1, 1, \dots \qquad \qquad (1)$$ or it ends up with the cycle $$145, 42, 20, 4, 16, 37, 58, 89, \dots \qquad (2)$$ repeated again and again.The number $n$ is happy if, starting with $n$, we end with 1,1,1,..., and sad if it ends up with 145,42,20, ... and so on.
In the first article we showed that if we started with any whole number from 1 to 999, then we always ended up with another number between 1 and 999. We then showed that because of this, if we repeat this process indefinitely we will always end up with some set of numbers being repeated over and over again. Of course, at this stage we didn't know that these sets had to be (1) or (2); in fact, we didn't even know how many sets there might be.
In the second article, we showed that if we reach the situation where a single number was repeated over and over again, then that number has to be 1; it is not possible, for example, to start with some whole number and end with the number 57 repeated over and over again. Just to make sure you really do understand what is happening here, I suggest that you (and your friends) see how many numbers between, say 20 and 30, end up at the number 1.
Here, we shall
(A) show that whatever whole number we start with (and it can now be as large as you like), we will always end up with some set of numbers being repeated over and over again, and
(B) explain why (1) and (2) are the only two possibilities.
Suppose that we start with a very large number, say 9,876,543,210. We say that this is a ten digit number because it has ten places `filled in'; similarly 123,456,789 is a nine digit number. Now apply the rule `sums of squares' to both of these; what do you notice? How many digits does the answer have? Try three more nine digit numbers for yourself; how many digits do these answers have? Now try to find a nine digit number whose answer is 712 or larger. How many nine digit numbers are there whose answer is 712 or larger? Can you find a nine digit number whose answer is 730? If you can, then find out how many there are; if you can't, then explain why not. How many nine digit numbers are there whose answers lie between 713 and 728 inclusive?
It is now easy to see what is happening in general. If, for example, we have 7 in the thousands digit, this contributes 7,000 to the number but only 49 to the answer. Similarly, if we have the number 53,426 the digits 5 and 3 contribute 53,000 to the number and only $5^2$ and $3^2$ to the answer. It should now be clear that starting with a large number $N$ that is at least 1,000 the answer is LESS than the number $N$. This means that if we start with a large number, and apply the rule repeatedly, eventually we will get an answer that is less than 1,000. At this point, we know from the first of these articles that whatever whole number we start with we will eventually end up with a some set of numbers being repeated over and over again, so we see that (A) is true.
Let us now consider (B). We know now that wherever we start we will eventually end up with a number with at most three digits. At this point, if we apply the rule again, we end up with a number which is at most $3 \times 9^2 = 243$. If we apply the rule again, the largest answer we can get is the largest of the answers we get from the three numbers 199, 239 and 243; can you explain to a friend or your teacher why this is so? As these three answers are $$1^2 + 9^2 + 9^2 = 163,$$ $$2^2 + 3^2 + 9^2 = 94,$$ $$2^2 + 4^2 + 3^2 = 29,$$ we now know that wherever we start, we will always eventually reach a number that is at most 163. If we now check all starting points from 1 to 163 (admittedly this is a lot of work, and you may like to share the task out among your friends, but I know of no other way than this) we see that the only possibilities are (1) and (2). This completes the discussion of the Happy Numbers Problem and gives the complete solution of it.