Most recent change of HappyNumber

Edit made on March 10, 2009 by DerekCouzens at 11:12:05

Deleted text in red / Inserted text in green

WW
HEADERS_END
A happy number Happy Number is one where the repeated process of squaring and adding the digits eventually gives an answer of 1.

For example: 13

* EQN:13->1^{2}+3^{2}=1+9=10
* EQN:10->1^{2}+0^{2}=1
* EQN:1->1^2=1 ... and so on.

If a sequence like this reaches 1 it will stay there.
13 is a Happy Number!

However some numbers do not reach one. For example: 14

* EQN:14->1^{2}+4^{2}=1+16=17
* EQN:17->1^{2}+7^{2}=1+49=50
* EQN:50->5^{2}+0^{2}=25
* EQN:25->2^{2}+5^{2}=4+25=29
* EQN:29->2^{2}+9^{2}=4+81=85
* EQN:85->8^{2}+5^{2}=64+25=89
* EQN:89->8^{2}+9^{2}=64+81=145
* EQN:145->1^{2}+4^{2}+5^{2}=1+16+25=42
* EQN:42->4^{2}+2^{2}=16+4=20
* EQN:20->2^{2}+0^{2}=4
* EQN:4->4^{2}=16
* EQN:16->1^{2}+6^{2}=1+36=37
* EQN:37->3^{2}+7^{2}=9+49=58
* EQN:58->5^{2}+8^{2}=25+64=89
which we've seen before...

14 is an Unhappy Number.

This procedure is an example of a Number Chain
----

* http://en.wikipedia.org/wiki/Happy_number
* http://mathworld.wolfram.com/HappyNumber.html