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
12+32=10
12+02=1

On the other hand, 4 is not a happy number because the sequence starting with
42=16
12+62=37
32+72=58
52+82=89
82+92=145
12+42+52=42
42+22=20
22+02=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.