IP331.com | Online Tools
HomeNumber Theory ToolsHappy Number Checker

Happy Number Checker

Enter a positive integer to test if it is happy (reaches 1) or unhappy (enters the 4-16-37 cycle)

Enter Number

Happy Number Definition

n -> sum of squares of digits
Repeat until reaching 1 (happy) or entering cycle
Unhappy cycle: 4 -> 16 -> 37 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4
Example: 19 -> 82 -> 68 -> 100 -> 1 (happy)

Happy numbers are defined by an iterative digit-square-sum process that either reaches 1 (happy) or enters a specific 8-number cycle (unhappy). The concept was popularized by mathematician Arthur Porges in 1945.

All unhappy numbers eventually enter the 4-16-37-58-89-145-42-20 cycle. This is proven for all positive integers.

What Is a Happy Number?

A happy number is a positive integer that reaches 1 when repeatedly replacing it with the sum of squares of its digits. If it enters the unhappy cycle instead, it is called an unhappy or sad number. About one in seven numbers is happy.

Happy Process

Sum squares of digits, replace, repeat. 19: 1+81=82, 64+4=68, 36+64=100, 1+0+0=1. Happy! Reaches 1.

Unhappy Cycle

Numbers like 2, 3, 4, 5 enter a cycle: 4->16->37->58->89->145->42->20->4. They never reach 1.

Prime Happy

Happy primes are happy numbers that are also prime: 7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239...

Infinity

There are infinitely many happy numbers. The asymptotic density is about 0.144. For n-digit numbers, ~14.4% are happy.

Teaching Example: n=19. 1^2+9^2=1+81=82. 8^2+2^2=64+4=68. 6^2+8^2=36+64=100. 1^2+0^2+0^2=1. Reached 1 in 4 steps! 19 is happy. Try 4: 4^2=16, 1+36=37, 9+49=58, 25+64=89, 64+81=145, 1+16+25=42, 16+4=20, 4+0=4. Cycle! 4 is unhappy.

Applications

Recreational Math Digit Analysis Number Theory Puzzles Education Competitions

FAQs about Happy Numbers

What is a happy number?
A number whose digit-square-sum iteration reaches 1. 19->82->68->100->1 is happy. Numbers reaching the 4-cycle are unhappy.
Is 1 happy?
Yes! 1^2 = 1. It is trivially happy (already at 1). All powers of 10 (10, 100, 1000) are happy because they sum to 1.
What is the unhappy cycle?
4,16,37,58,89,145,42,20,4. Every unhappy number eventually enters this cycle. 2->4 enters immediately. 3->9->81->65->61->37 enters.
How many happy numbers exist?
Infinitely many. Density is about 14.4%. First few: 1,7,10,13,19,23,28,31. Happy primes: 7,13,19,23,31,79,97.

More Number Theory Tools

Free online calculators and tools covering mathematics, unit conversion, text processing, and daily life. Accurate, fast, mobile-friendly, and completely free to use.

© 2026 IP331.com — Free Online Tools. All rights reserved.

About · Contact · Privacy Policy · Cookie Policy · Terms of Use · Disclaimer · Sitemap