Welcome to NRICH.

 
Number chains (happy numbers)


By Anonymous on Tuesday, May 9, 2000 - 10:45 am:

Many two digit numbers join a chain if they undergo this process:-
square each digit and add the squares
eg. 16 1 squared + 6 squared=37
3 squared + 7 squared=58
5 squared + 8 squared=89
8 squared + 9 squared=145
1 squared + 4 squared + 5 squared=42
4 squared + 2 squared=20
2 squared + 0 squared=4
4 squared=16

This works with the majority of numbers 10 - 100 (I've checked). I don't understand why this would happen. Not every number works - 1, 10 or any numbers whose digits squared = 10 obviously doesn't join the chain. Anyone know?

Anonymous


By Alex Barnard (Agb21) on Monday, May 15, 2000 - 11:11 am:

Okay the reason is as follows. Firstly I need to convince you that the operation you describe basically always decreases the number you input.

Suppose I have an n-digit number, so the maximum it can be is 10n-1 and the minimum is 10n-1. The maximum that the processed number can be is if everything was 9's and we would get 81×n.

Now, for n>3 convince yourself that 10n-1 is much bigger than 81×n and hence for 4 (or more) digit numbers the operation WILL decrease the number.

So what happens is as follows. After a couple of operations we can guarantee that the number is always at most a 4-digit number and hence because there are only a finite number of these the operation must eventually repeat a number and then it will fall into a loop.

This only answers why numbers fall into a loop eventually (ie. 10 falls into the loop 1-1-1-1...) but this is a much more normal thing to check than actually being part of the loop. Very large numbers can never be part of a loop (because of what was said earlier about decreasing outputs) but they are always part of a 'tail' leading up to a loop.

If any of that didn't make sense please write back.

AlexB.