# Happy numbers

**URL:** <https://boards.straightdope.com/t/happy-numbers/496826>\
**Category:** Factual Questions\
**Created:** [May 18, 2009, 5:07am UTC](https://boards.straightdope.com/t/happy-numbers/496826 "2009-05-18T05:07:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![copperwindow](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@copperwindow](https://boards.straightdope.com/u/copperwindow)\
**Post date:** [May 18, 2009, 5:07am UTC](https://boards.straightdope.com/t/happy-numbers/496826/1 "2009-05-18T05:07:28Z")

</div>

Can someone explain to me what a happy number is? Wikipedia tried explaining it to me, but I’m still confused.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [May 18, 2009, 5:47am UTC](https://boards.straightdope.com/t/happy-numbers/496826/2 "2009-05-18T05:47:24Z")

</div>

3, because if you tilt it sideways it looks like it’s smiling.

OK, maybe not.

To find if a given number is happy, you must perform the following algorithm:

1. Start with a number _n_
2. Find the sum of the squares of the digits of _n_
3. If the result is 1, the number is happy, otherwise, reset _n_ to the result, and goto 2.

For example, let’s try the number 23.

First find the sum of the squares of the digits:

2[sup]2[/sup] + 3[sup]2[/sup] = 4 + 9 = 13

Does 13 equal 1? Nope. So repeat:

1[sup]2[/sup] + 3[sup]2[/sup] = 1 + 9 = 10

10 is not 1, so

1[sup]2[/sup] + 0[sup]2[/sup] = 1 + 0 = 1

1 equals 1! So 23 is a happy number.

For numbers which are not happy, you just end up going in circles forever.

---

<div class="post-metadata">

**Author:** ![copperwindow](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@copperwindow](https://boards.straightdope.com/u/copperwindow)\
**Post date:** [May 18, 2009, 6:09am UTC](https://boards.straightdope.com/t/happy-numbers/496826/3 "2009-05-18T06:09:43Z")

</div>

> [@friedo](#):
>
> 3, because if you tilt it sideways it looks like it’s smiling.
> 
> OK, maybe not.
> 
> To find if a given number is happy, you must perform the following algorithm:
> 
> 1. Start with a number _n_
> 2. Find the sum of the squares of the digits of _n_
> 3. If the result is 1, the number is happy, otherwise, reset _n_ to the result, and goto 2.
> 
> For example, let’s try the number 23.
> 
> First find the sum of the squares of the digits:
> 
> 2[sup]2[/sup] + 3[sup]2[/sup] = 4 + 9 = 13
> 
> Does 13 equal 1? Nope. So repeat:
> 
> 1[sup]2[/sup] + 3[sup]2[/sup] = 1 + 9 = 10
> 
> 10 is not 1, so
> 
> 1[sup]2[/sup] + 0[sup]2[/sup] = 1 + 0 = 1
> 
> 1 equals 1! So 23 is a happy number.
> 
> For numbers which are not happy, you just end up going in circles forever.

Step 2 confuses me. What is the sum of the squares? Wiki says for the number 7: 1) 72 = 49 2) 42 + 92 = 97 3 )92 + 72 = 130 How do they come up with 130? The first two steps, I understand now.

---

<div class="post-metadata">

**Author:** ![copperwindow](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@copperwindow](https://boards.straightdope.com/u/copperwindow)\
**Post date:** [May 18, 2009, 6:11am UTC](https://boards.straightdope.com/t/happy-numbers/496826/4 "2009-05-18T06:11:46Z")

</div>

> [@copperwindow](#):
>
> Step 2 confuses me. What is the sum of the squares? Wiki says for the number 7: 1) 72 = 49 2) 42 + 92 = 97 3 )92 + 72 = 130 How do they come up with 130? The first two steps, I understand now.

The “2”'s, are actually squares.

---

<div class="post-metadata">

**Author:** ![Cunctator](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Cunctator](https://boards.straightdope.com/u/Cunctator)\
**Post date:** [May 18, 2009, 6:15am UTC](https://boards.straightdope.com/t/happy-numbers/496826/5 "2009-05-18T06:15:32Z")

</div>

> [@copperwindow](#):
>
> Step 2 confuses me. What is the sum of the squares? Wiki says for the number 7: 1) 72 = 49 2) 42 + 92 = 97 3 )92 + 72 = 130 How do they come up with 130? The first two steps, I understand now.

Start with 7. It has only one digit:

7[sup]2[/sup] = 49

49 has two digits:

4[sup]2[/sup] + 9[sup]2[/sup] = 16 + 81 = 97

97 has two digits:

9[sup]2[/sup] + 7[sup]2[/sup] = 81 + 49 = 130

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [May 18, 2009, 6:19am UTC](https://boards.straightdope.com/t/happy-numbers/496826/6 "2009-05-18T06:19:11Z")

</div>

The point is, you have to repeat the process until you get 1 or end up in a loop.

So, start with 7, which has only one digit. So the sum of the squares of the digits is

7[sup]2[/sup] + (nothing) = 49.

Then we take the digits of 49, and square them, and find _their_ sum:

4[sup]2[/sup] + 9[sup]2[/sup] = 16 + 81 = 97

Now we find the sums of the squares of the digits of 97:

9[sup]2[/sup] + 7[sup]2[/sup] = 81 + 49 = 130

Now find the sum of the squares of the digits 1, 3 and 0:

1[sup]2[/sup] + 3[sup]2[/sup] + 0[sup]2[/sup] = 1 + 9 + 0 = 10

And finally:

1[sup]2[/sup] + 0[sup]2[/sup] = 1 + 0 = 1

---

<div class="post-metadata">

**Author:** ![copperwindow](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@copperwindow](https://boards.straightdope.com/u/copperwindow)\
**Post date:** [May 18, 2009, 6:23am UTC](https://boards.straightdope.com/t/happy-numbers/496826/7 "2009-05-18T06:23:27Z")

</div>

> [@Cunctator](#):
>
> 81 + 49 = 130

Doesn’t 81 + 49 equal 930?

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [May 18, 2009, 6:44am UTC](https://boards.straightdope.com/t/happy-numbers/496826/8 "2009-05-18T06:44:03Z")

</div>

> [@copperwindow](#):
>
> Doesn’t 81 + 49 equal 930?

Not usually…

---

<div class="post-metadata">

**Author:** ![Exapno\_Mapcase](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/exapno_mapcase/32/1051_2.png) [@Exapno\_Mapcase](https://boards.straightdope.com/u/Exapno_Mapcase)\
**Post date:** [May 18, 2009, 2:09pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/9 "2009-05-18T14:09:43Z")

</div>

> [@copperwindow](#):
>
> Doesn’t 81 + 49 equal 930?

In today’s advanced exam, find a number base in which this equation is true. You may use all your fingers and toes.

---

<div class="post-metadata">

**Author:** ![Chessic\_Sense](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@Chessic\_Sense](https://boards.straightdope.com/u/Chessic_Sense)\
**Post date:** [May 18, 2009, 3:46pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/10 "2009-05-18T15:46:19Z")

</div>

> [@Exapno\_Mapcase](#):
>
> In today’s advanced exam, find a number base in which this equation is true. You may use all your fingers and toes.

I get 5/3.

---

<div class="post-metadata">

**Author:** ![Erasmus\_Darwin](https://avatars.discourse-cdn.com/v4/letter/e/c57346/32.png) [@Erasmus\_Darwin](https://boards.straightdope.com/u/Erasmus_Darwin)\
**Post date:** [May 18, 2009, 3:47pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/11 "2009-05-18T15:47:04Z")

</div>

> [@Exapno\_Mapcase](#):
>
> In today’s advanced exam, find a number base in which this equation is true. You may use all your fingers and toes.

Doesn’t work. Since the original equation has 9s in it, any base less than 10 doesn’t make sense. Starting with base 10, the sum of 81 and 49 is 130, and it needs to be 930. As we increase the base, 930 is going to grow significantly faster than the sum of 81 and 49. That’s because 930 is going to have 9 \* base^2 as its largest term versus (8+4)\*base for the sum. So the sum is never going to catch up to 930.

If we ignore the fact that having a base lower than 10 doesn’t make sense (since you can’t have a ‘9’ in a number in a base lower than 10) and just try and make the math work, there appears to be a solution with a non-integer base somewhere between 1 and 2.

Edit: Looks like Chessic Sense found it.

---

<div class="post-metadata">

**Author:** ![Full\_Metal\_Lotus](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Full\_Metal\_Lotus](https://boards.straightdope.com/u/Full_Metal_Lotus)\
**Post date:** [May 18, 2009, 5:12pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/12 "2009-05-18T17:12:08Z")

</div>

Just wondering, where/how in mathemetics are “Happy Numbers” used? What is the purpose of the “Happy Number” function?

Regards  
FML

---

<div class="post-metadata">

**Author:** ![Giles](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/giles/32/60_2.png) [@Giles](https://boards.straightdope.com/u/Giles)\
**Post date:** [May 18, 2009, 5:31pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/13 "2009-05-18T17:31:08Z")

</div>

> [@Full\_Metal\_Lotus](#):
>
> Just wondering, where/how in mathemetics are “Happy Numbers” used? What is the purpose of the “Happy Number” function?

As far as I can see, no practical use exists. This is quite common with pure mathematics.

---

<div class="post-metadata">

**Author:** ![KneadToKnow](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kneadtoknow/32/3999_2.png) [@KneadToKnow](https://boards.straightdope.com/u/KneadToKnow)\
**Post date:** [May 18, 2009, 6:08pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/14 "2009-05-18T18:08:30Z")

</div>

69 is a happy number.

---

<div class="post-metadata">

**Author:** ![copperwindow](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@copperwindow](https://boards.straightdope.com/u/copperwindow)\
**Post date:** [May 18, 2009, 6:23pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/15 "2009-05-18T18:23:09Z")

</div>

I’m not sure why I thought yesterday that it was 930, but I think I finally understand it. Thanks all, I really appreciate it.

---

<div class="post-metadata">

**Author:** ![Full\_Metal\_Lotus](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Full\_Metal\_Lotus](https://boards.straightdope.com/u/Full_Metal_Lotus)\
**Post date:** [May 18, 2009, 7:13pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/16 "2009-05-18T19:13:15Z")

</div>

> [@Giles](#):
>
> As far as I can see, no practical use exists. This is quite common with pure mathematics.

so… “That’s the beauty of it… it doesn’t do anything!” applies here?

grin  
FML

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [May 18, 2009, 7:18pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/17 "2009-05-18T19:18:57Z")

</div>

> [@](#):
>
> 69 is a happy number.

You were probably joking, but…

69  
36+81 = 117  
1+1+49 = 51  
25+1 = 26  
4+36 = 40  
16+0 = 16  
1+36 = 37  
9+49 = 58  
25+64 = 89  
64+81 = 145  
1+16+25 = 42  
16+4 = 20  
4+0 = 4  
16

So 69 loops back on itself.

---

<div class="post-metadata">

**Author:** ![Giles](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/giles/32/60_2.png) [@Giles](https://boards.straightdope.com/u/Giles)\
**Post date:** [May 18, 2009, 7:21pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/18 "2009-05-18T19:21:56Z")

</div>

> [@Chronos](#):
>
> You were probably joking, but…
> 
> …
> 
> So 69 loops back on itself.

How very appropriate – so it should be a pair of happy numbers 😃

---

<div class="post-metadata">

**Author:** ![gazpacho](https://avatars.discourse-cdn.com/v4/letter/g/6f9a4e/32.png) [@gazpacho](https://boards.straightdope.com/u/gazpacho)\
**Post date:** [May 18, 2009, 7:22pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/19 "2009-05-18T19:22:19Z")

</div>

> [@Giles](#):
>
> As far as I can see, no practical use exists. This is quite common with pure mathematics.

Dangerous word here. 15 years from now someone is going to have a slightly better coding algorithm based on happy numbers. Thus getting one more phone call per base station or slightly more bits per square centimeter on the disk drive platter.

---

<div class="post-metadata">

**Author:** ![KneadToKnow](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kneadtoknow/32/3999_2.png) [@KneadToKnow](https://boards.straightdope.com/u/KneadToKnow)\
**Post date:** [May 18, 2009, 8:01pm UTC](https://boards.straightdope.com/t/happy-numbers/496826/20 "2009-05-18T20:01:02Z")

</div>

> [@Chronos](#):
>
> So 69 loops back on itself.

Wow. That’s the first persuasive argument for numerology I’ve ever heard! 😃

[Next page](https://boards.straightdope.com/t/happy-numbers/496826.md?page=2)
