Never tickle a sleeping dragon.
Thursday, March 13, 2008
Happy Numbers
There are happy words -- usually colorful metaphors used to describe someone who has pissed you off.
Then there are happy numbers -- numbers in which you repeatedly sum the squares of the digits, until you've reduced the number to 1.
I first learned of happy numbers from Doctor Who. Martha Jones was trying to get through a series of locked doors, with each door looking for the answer to a riddle as a password. "What number is next in this sequence: 313, 331, 367?" Martha didn't know, so asked The Doctor over the com, causing The Doctor to comment on the lack of recreational mathematics in human education.
The answer? 379. Here's how to calculate a happy number...
Separate the number into its digits, square them, and add them. Repeat the process for the result, until you reach 1. If at any point the result repeats a previous number in the sequence, it isn't happy. Using 379 as an example...
379 -> 9 + 49 + 81 = 139
139 -> 1 + 9 + 81 = 91
91 -> 81 + 1 = 82
82 -> 64 + 4 = 68
68 -> 36 + 64 = 100
100 -> 1 + 0 + 0 = 1
So, 379 is a happy number (or in this case, a happy prime).
The name of the Doctor who episode was 42, which is significant in it's own right, being the ultimate answer to the great question of life, the universe, and everything. Sadly, though, 42 is not a happy number. It does have another interesting characteristic, however, in that it demonstrates its unhappiness be repeating itself...
42 -> 16 + 4 = 20
20 -> 4 + 0 = 4
4 -> 16
16 -> 1 + 36 = 37
37 -> 9 + 49 = 58
58 -> 25 + 64 = 89
89 -> 64 + 81 = 145
145 -> 1 + 16 + 25 = 42
Then there are happy numbers -- numbers in which you repeatedly sum the squares of the digits, until you've reduced the number to 1.
I first learned of happy numbers from Doctor Who. Martha Jones was trying to get through a series of locked doors, with each door looking for the answer to a riddle as a password. "What number is next in this sequence: 313, 331, 367?" Martha didn't know, so asked The Doctor over the com, causing The Doctor to comment on the lack of recreational mathematics in human education.
The answer? 379. Here's how to calculate a happy number...
Separate the number into its digits, square them, and add them. Repeat the process for the result, until you reach 1. If at any point the result repeats a previous number in the sequence, it isn't happy. Using 379 as an example...
379 -> 9 + 49 + 81 = 139
139 -> 1 + 9 + 81 = 91
91 -> 81 + 1 = 82
82 -> 64 + 4 = 68
68 -> 36 + 64 = 100
100 -> 1 + 0 + 0 = 1
So, 379 is a happy number (or in this case, a happy prime).
The name of the Doctor who episode was 42, which is significant in it's own right, being the ultimate answer to the great question of life, the universe, and everything. Sadly, though, 42 is not a happy number. It does have another interesting characteristic, however, in that it demonstrates its unhappiness be repeating itself...
42 -> 16 + 4 = 20
20 -> 4 + 0 = 4
4 -> 16
16 -> 1 + 36 = 37
37 -> 9 + 49 = 58
58 -> 25 + 64 = 89
89 -> 64 + 81 = 145
145 -> 1 + 16 + 25 = 42
Labels: Doctor Who
