In number theory, a happy number is a number that reaches the number 1 when the number is replaced by the sum of the square of each digit. For example, 13 is a happy number because and On the other hand, 4 is not a happy number because the sequence starting with and reaches , the number that started the sequence, and so the process continues in an infinite cycle but will never reach 1. A number which is not happy is called sad or unhappy.