What are "Happy Numbers" and "Unhappy Numbers?"



Happy/Unhappy Number Checker
Squares              Cubes

Enter a positive integer with at most 15 digits below:

 

In recreational mathematics, the so-called "happy numbers" and "unhappy numbers" are integers that produce particular sequences when you repeatedly square the number's digits and compute the sum of those squares.

One of two outcomes can occur when you apply this summation process over and over: (i) the sum will stabilize at 1, or (ii) the sum will stabilize in a loop that repeats forever.

Integers that stabilize at 1 are called "happy numbers" and integers that fall into the loop are called "unhappy numbers."

We explain how to determine whether an integer is happy or unhappy with examples below. You can also use the happy number checker on the left. Learning about square numbers and sequences through the happy integers can be a fun project for elementary school children.

Example 1: A Happy Number

The number 67121 is a happy number because its summation sequence stabilizes at 1. Observe:

67121 ---- 62 + 72 + 12 + 22 + 12 = 36 + 49 + 1 + 4 + 1 = 91
91 -------- 92 + 12 = 81 + 1 = 82
82 -------- 82 + 22 = 64 + 4 = 68
68 -------- 62 + 82 = 36 + 64 = 100
100 ------ 12 + 02 + 02 = 1 + 0 + 0 = 1
1 --------- 12 = 1
1 --------- 12 = 1...

All of the happy numbers less than 200 are 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100, 103, 109, 129, 130, 133, 139, 167, 176, 188, 190, 192, and 193.

If a number is happy, then you can generate another happy number just by rearranging the digits and inserting 0's. For instance, since we determined that 67121 is happy, it implies that 72116, 1102076, 702611, etc are also happy numbers.

Example 2: An Unhappy Number

If a number's summation sequence does not stabilize at 1, then it stabilizes in this loop of 8 numbers:

...4 -- 16 -- 37 -- 58 -- 89 -- 145 -- 42 -- 20 -- 4 -- 16 -- 37 -- 58...

For example, if we start with the number 34782, we will eventually repeate the cycle of numbers above. Watch:

34782 ---- 32 + 42 + 72 + 82 + 22 = 9 + 16 + 49 + 64 + 4 = 142
142 ------- 12 + 42 + 22 = 1 + 16 + 4 = 21
21 -------- 22 + 12 = 4 + 1 = 5
5 ---------- 52 = 25
25 -------- 22 + 52 = 4 + 25 = 29
29 -------- 22 + 92 = 4 + 81 = 85
85 -------- 82 + 52 = 64 + 25 = 89
89 -------- 82 + 92 = 64 + 81 = 145
145 ------ 12 + 42 + 52 = 1 + 16 + 25 = 42
42 -------- 42 + 22 = 16 + 4 = 20
20 -------- 22 + 02 = 4 + 0 = 4
4 --------- 42 = 16
16 -------- 12 + 62 = 1 + 36 = 37
37 -------- 32 + 72 = 9 + 49 = 58
58 -------- 52 + 82 = 25 + 64 = 89
89 -------- 82 + 92 = 64 + 81 = 145...

You can generalize the concept of happy/unhappy numbers by replacing the squaring operation with a different operation. In particular, if you cube the numbers instead of squaring them, you get more interesting behavior as explained below.

Happy Cube Numbers

If you cube the digits of the number, add the cubes, and then repeat the process with the rusulting number, you will also generate a stable pattern that repeats indefinitely. If the process stabilizes at 1, you have a happy cube number. Otherwise, it will stabilize at one of the following eight cycles, in which case you have an unhappy cube number.

...55 -- 250 -- 133 -- 55 -- 250 -- 133...             (3-cycle)
...160 -- 217 -- 352 -- 160 -- 217 -- 352...         (3-cycle)
...136 -- 244 -- 136 -- 244...                            (2-cycle)
...919 -- 1459 -- 919 -- 1459...                         (2-cycle)
...153 -- 153 -- 153...                                      (1-cycle)
...370 -- 370 -- 370...                                      (1-cycle)
...371 -- 371 -- 371...                                      (1-cycle)
...407 -- 407 -- 407...                                      (1-cycle)

Example: The number 1234 is a happy cube number. Observe:

1234 -------- 13 + 23 + 33 + 43 = 1 + 8 + 27 + 64 = 100
100 --------- 13 + 03 + 03 = 1 + 0 + 0 = 1
1 ------------ 12 = 1
1 ------------ 12 = 1...



© Had2Know 2010

Δ Side, Angle, & Area Calculator

Printable Trig and Angles Cheat Sheet

Descriptive Statistics Calculator

How to Figure Half-Life from Two Measurements

Whether or Not a Number is Prime or Composite

How to Find the Prime Factorization of a Number with a Factor Tree