Thursday 17 July 2014

The dynamics of positive integers with regards to happy numbers

A happy number example
A number such as 334 is three hundred and thirty four with digits forming the multiset { 3, 3, 4 }
We then sum the squares of these digits: 3^2 + 3^2 + 4^2 = 9 + 9 + 16 = 34
Now we do the same for 34: 3^2 + 4^2 = 9 + 16 = 25
And iterating this process:
2^2 + 5^2 =  4 + 25 = 29
2^2 + 9^2 =  4 + 81 = 85
8^2 + 5^2 =  64 + 25 = 89
8^2 + 9^2 =  64 + 81 = 145
1^2 + 4^2 + 5^2 =  1 + 16 + 25 = 42
4^2 + 2^2 =  16 + 4 = 20
2^2 + 0^2 =  4 + 0 = 4
If we keep going there is a cycle:
4^2 = 16 ;  1^2 + 6^2 = 37 ;   3^2 + 7^2 = 58 ;   5^2 + 8^2 = 89 ;   and then 145, 42, 20, 4,  as before.
If the number enters into the cycle 4, 16, 37, 58, 89, 145, 42, 20, 4 the number is called “happy”.
The only other cycle is 1, 1, 1, 1, …
An interesting question is:  how do happy numbers “enter into” the cycle ?
For example, with 334, the number enters into the cycle at 89.
This visualisation shows the dynamics of this process for numbers 1 up to 40 using distinctive colours for the digit values 0, 1, 2, …, 9 and box borders to show where the number enters into a cycle.


No comments:

Post a Comment