Happy numbers

Happy numbers eventually reach 1 when you repeatedly replace the number with the sum of squares of its digits.

Math Calculators

Special Number Property Checker

Explore interactive step-by-step calculations and visual graphs for these numbers.

What Are Happy Numbers?

A happy number is an integer that eventually reaches 1 when replaced iteratively by the sum of the squares of its digits. If this process loops endlessly in a repeating cycle that excludes 1, the number is designated an unhappy (or sad) number:

1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100, …

Happy numbers provide a beautiful introduction to discrete dynamical systems, orbit cycles, and attractor basins.

The Digit-Square Iteration

Step-by-Step Example for 19

  1. 1² + 9² = 1 + 81 = 82
  2. 8² + 2² = 64 + 4 = 68
  3. 6² + 8² = 36 + 64 = 100
  4. 1² + 0² + 0² = 1 + 0 + 0 = 1 (Reached 1 → 19 is Happy!)

The Universal Unhappy Attractor Cycle

4 → 16 → 37 → 58 → 89 → 145 → 42 → 20 → 4

Every single unhappy number in base 10 eventually falls into this exact 8-number periodic orbit!

Mathematical Properties & Happy Primes

Happy Primes

Numbers that are both prime and happy: 7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239, 263, 293... No one knows if there are infinitely many happy primes.

Density of Happy Numbers

Approximately 14.4% of all positive integers are happy numbers. Among integers up to 1,000, exactly 143 are happy.

Consecutive Happy Numbers

The smallest pair of consecutive happy numbers is (31, 32). The smallest triplet is (1880, 1881, 1882).

Frequently Asked Questions

Why does the process always either reach 1 or cycle?

Because for numbers with 4 or more digits, the sum of squared digits is strictly smaller than the number itself (e.g. for 9,999, sum = 4 × 81 = 324 < 9999). This guarantees every trajectory enters a finite set of numbers below 243, where it must eventually repeat.

Is 7 a happy number?

Yes: 7² = 49 → 4² + 9² = 97 → 9² + 7² = 130 → 1² + 3² + 0² = 10 → 1² + 0² = 1.