Happy numbers
Tonight's idea
Pick a whole number. Square each digit and add the squares. Do the same to the answer, and keep going. From 7 you get \(7^2 = 49\), then \(4^2 + 9^2 = 97\), then \(81 + 49 = 130\), then \(1 + 9 + 0 = 10\), then \(1\). After that nothing changes, because \(1^2 = 1\). A number whose chain reaches 1 is called happy.
Now try 2. It goes to 4, then 16, 37, 58, 89, 145, 42, 20, and back to 4. It is caught in a loop of eight numbers. It never reaches 1, so 2 is not happy.
Here is the surprise. Those are the only two endings. Every whole number from 1 up either arrives at 1 or falls into this same loop. Big numbers shrink fast (999 drops to 243 in one step), so only small ones need testing, and a computer can test them all.
Reach 1: happy. Reach any number in the loop: not happy.
Watch one: is 19 happy? Is 5?
19. \(1 + 81 = 82\). Then \(64 + 4 = 68\), then \(36 + 64 = 100\), then \(1 + 0 + 0 = 1\). Happy, in four steps.
5. \(25\), then \(4 + 25 = 29\), then \(4 + 81 = 85\), then \(64 + 25 = 89\). Stop there: 89 is in the loop, so the chain will circle for ever. 5 is not happy.
You can stop as soon as you meet a number whose ending you already know.
A cousin of this game, whose ending nobody has managed to prove: mathdetours.com/demos/collatz.html.
Your turn
- Follow the chain for (a) 23 and (b) 3. Say whether each number is happy.
- 13 is happy: it goes 13, 10, 1. Without squaring anything else, explain why 31, 103 and 1,300 must be happy too.
- Test (a) 44, (b) 28 and (c) 15. Stop each chain as soon as you reach a number you have met on this sheet.
- (a) What does 999 go to in one step? (b) Why can no three-digit number go to anything bigger? (c) So a chain that is below 1,000 stays below 1,000. Explain why it must then come back to a number it has already visited.
Stretch: happy neighbours
The happy numbers up to 30 are 1, 7, 10, 13, 19, 23 and 28. No two of them are next to each other. Find the first pair of happy numbers that are next-door neighbours, like 5 and 6 would be. Question 2 gives you one of the pair for free.
Answers
- (a) \(4 + 9 = 13\), then \(1 + 9 = 10\), then 1. Happy. (b) \(9\), then \(81\), then \(64 + 1 = 65\), then \(36 + 25 = 61\), then \(36 + 1 = 37\), which is in the loop. Not happy.
- The order of the digits does not matter when you add their squares, and a 0 adds nothing because \(0^2 = 0\). So 31, 103 and 1,300 all give \(1 + 9 = 10\) on the first step, just as 13 does, and then 1.
- (a) \(16 + 16 = 32\), then \(9 + 4 = 13\), which is happy. So 44 is happy. (b) \(4 + 64 = 68\), which was in the chain for 19 and leads to 100 and 1. Happy. (c) \(1 + 25 = 26\), then \(4 + 36 = 40\), then \(16\), which is in the loop. Not happy.
- (a) \(81 + 81 + 81 = 243\). (b) No digit is bigger than 9, so no square is bigger than 81, and three of them make at most 243. (c) There are only 999 whole numbers below 1,000. A chain that never repeated would need a new one at every step, and it would run out. Once a number comes up a second time, everything after it repeats too. That is why every chain ends in a loop. (1 on its own counts as a loop of one.)
Stretch. 31 and 32. 31 has the same digits as 13, so it is happy. 32 gives \(9 + 4 = 13\), so it is happy as well. Checking 29 and 30 shows neither is happy (29 leads to 85 and 89; 30 leads to 9, like 3), so there is no earlier pair.