Happy number

A happy number is a natural number as output value for a particular iteration after a finite number of iterations to the value 1, similar to the Collatz problem.

Definition

For a natural number with the decimal, where and are squared and added, i.e. each digit is calculated. The resulting number is treated the same way. If, at some point as a result of a 1, then all following figures also this value, and the number is called cheerfully. The only alternative is the transition to the single, comprehensive eight numbers, periodic cycle ( 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20 → 4). Further cycles do not exist.

Examples of happy numbers

A number in a sequence is only happy when all the numbers are happily in the episode.

The first 20 numbers are cheerful:

Example of sad (not fun) numbers

Merry primes

Prime numbers that are merry, cheerful called prime numbers:

The 91 is a fun pseudo-prime. The Carmichael number 1729 is the product of the first three prime numbers cheerful.

354218
de