In number theory, a happy number is a number which eventually reaches 1 when replaced by the **sum of the square of each digit**.

For instance, 13 is a happy number because

1^{2}+3^{2}=10

1^{2}+0^{2}=1

On the other hand, 4 is not a happy number because the sequence starting with

4^{2}=16

1^{2}+6^{2}=37

3^{2}+7^{2}=58

5^{2}+8^{2}=89

8^{2}+9^{2}=145

1^{2}+4^{2}+5^{2}=42

4^{2}+2^{2}=20

2^{2}+0^{2}=4

This is the number that started the sequence, and so the process continues in an infinite cycle without ever reaching 1. A number which is not happy is called sad or unhappy.