Search a number
happy numbers
Let us define a function  $s(n)$, for  $n>0$, which gives the sum of the squares of the digits of  $n$, so, for example,  $s(37)=3^2+7^2=58$.

If we start from a number  $n$  and we repeatedly apply  $s(\cdot)$, we obtain a sequence  $S_n$  of numbers  $n$,  $s(n)$,  $s(s(n)),\dots$, and so on.

A number  $n$  is called happy if  $S_n$  contains the number 1.

Note that  $s(1)=1$, so in that case the sequence  $S_n$  has an infinite tail of  $1$'s.

If a number is not happy then it is easy to see that at a certain point  $S_n$  will enter the infinite loop

\[\dots,4, 16, 37, 58, 89, 145, 42, 20, 4,\dots\]
So, for example, starting from  $94$  we obtain  $94\rightarrow97\rightarrow130\rightarrow10\rightarrow1$, so  $94$  is happy. See figure aside.

On the contrary, starting from 61 we obtain  $61\rightarrow37\rightarrow58\rightarrow89$  and thus 61 is not happy, since 89 belongs to the unhappy loop.

The first  $k$-tuple of consecutive happy numbers, for  $k=2,\dots,5$  starts at 31, 1880, 7839, and 44488, respectively.

E. El-Sedy & S. Siksek proved that there can be runs of arbitrary length.

There are 3, 20, 143, 1442, 14377, 143071,... happy numbers up to 10, 100, 1000,....

The smallest 3 × 3 magic square whose entries are happy numbers is

9071188635
6389101182
1185632913

The first happy numbers 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 more terms

Happy numbers can also be... (you may click on names or numbers and on + to get more values)

a-pointer 13 103 293 + 9951101 ABA 32 192 338 + 9910152 aban 10 13 19 + 10000000 abundant 70 100 176 + 10000000 Achilles 392 1125 1152 + 9940500 admirable 70 368 464 + 9998574 alt.fact. 19 alternating 10 23 32 + 9898921 amenable 13 28 32 + 10000000 amicable 1184 2620 10744 + 9892936 apocalyptic 192 226 478 + 29994 arithmetic 13 19 23 + 9999992 astonishing 1353 21762 23287 2732353 automorphic 376 109376 balanced p. 263 563 653 + 9996823 Bell 203 bemirp 1106881 1886011 betrothed 1575 549219 587460 + 7890575 binomial 10 28 70 + 9988215 brilliant 10 49 319 + 9999697 c.decagonal 31 3001 5281 + 9863101 c.heptagonal 386 638 736 + 9931391 c.nonagonal 10 28 91 + 9956953 c.octagonal 49 1521 4225 + 9966649 c.pentagonal 31 226 331 + 9875391 c.square 13 313 365 + 9985981 c.triangular 10 19 31 + 9988471 cake 130 176 4090 + 8580119 Canada 16999 Carmichael 62745 252601 658801 + 9439201 Carol 16127 Catalan 16796 9694845 Chen 13 19 23 + 9999991 compositorial 192 congruent 13 23 28 + 9999992 constructible 10 32 68 + 8912896 cube 1000 4096 12167 + 8998912 Cullen 4609 2228225 Cunningham 10 28 31 + 9991920 Curzon 86 230 293 + 9999954 cyclic 13 19 23 + 9999991 D-number 129 219 291 + 7042773 d-powerful 226 262 376 + 9998724 de Polignac 331 907 1211 + 9999983 decagonal 10 637 2425 + 9980860 deceptive 91 3367 4187 + 9439201 deficient 10 13 19 + 9999992 dig.balanced 10 19 44 + 9999919 double fact. 135135 645120 2027025 droll 33280 174080 192000 + 9461760 Duffinian 32 49 100 + 9999983 eban 32 44 2030 + 6066050 economical 10 13 19 + 10000000 emirp 13 31 79 + 9999713 emirpimes 49 94 129 + 9999967 enlightened 219488 236196 equidigital 10 13 19 + 9999991 eRAP 1274 13350 13775 + 9960047 esthetic 10 23 32 + 9878767 Eulerian 302 2036 32752 1479726 evil 10 23 68 + 10000000 fibodiv 19 28 2602 + 8737446 Fibonacci 13 2584 4181 + 3524578 Friedman 736 1285 4096 + 999964 frugal 1029 1215 1875 + 10000000 gapful 100 130 176 + 10000000 Gilda 49 440 683 + 4848955 good prime 97 331 563 + 9993337 harmonic 28 496 8128 + 4713984 Harshad 10 70 100 + 10000000 heptagonal 469 874 970 + 9987004 hex 19 91 331 + 9975457 hexagonal 28 91 190 + 9988215 highly composite 15120 45360 55440 + 2162160 hoax 94 319 391 + 9999355 Hogben 13 31 91 + 9988761 Honaker 263 1039 1933 + 9982211 house 32 1285 2847 + 9418784 hungry 2003 82810 hyperperfect 28 301 496 + 6392257 iban 10 23 44 + 777443 iccanobiF 13 836 1454698 idoneal 10 13 28 + 280 impolite 32 4096 4194304 8388608 inconsummate 326 383 386 + 999938 interprime 86 129 176 + 9999372 Jacobsthal 683 5592405 Jordan-Polya 32 192 1152 + 9437184 junction 103 109 208 + 9999945 Kaprekar 17344 208495 390313 + 8161912 katadrome 10 31 32 + 9876543 Kynea 23 79 Lehmer 91 133 763 + 9969961 Leyland 32 100 320 + 4194788 lonely 23 15704 15705 + 2010805 Lucas 1860498 lucky 13 31 49 + 9999553 Lynch-Bell 784 4172 4872 + 864312 m-pointer 23 2111 15121 + 1111211 magic 671 5335 8801 + 9095855 magnanimous 23 32 49 + 9777910 metadrome 13 19 23 + 3456789 modest 13 19 23 + 9983333 Moran 133 190 888 + 9999802 Motzkin 2188 5798 nialpdrome 10 31 32 + 10000000 nonagonal 2484 4959 5781 + 9980301 nude 44 784 888 + 9999864 O'Halloran 44 oban 10 13 19 + 998 octagonal 133 176 280 + 9727201 odious 13 19 28 + 9999992 Ormiston 56179 56197 63179 + 9947473 palindromic 44 262 313 + 9992999 palprime 313 383 11311 + 9935399 pancake 79 301 326 + 9997157 panconsummate 10 23 31 + 3097 pandigital 19 694 970 + 9998037 partition 176 490 1575 + 7089500 pentagonal 70 176 376 + 9890652 perfect 28 496 8128 pernicious 10 13 19 + 9999992 Perrin 10 68 367 + 2968530 Pierpont 13 19 97 + 52489 plaindrome 13 19 23 + 7788999 Poulet 12801 18705 60701 + 9439201 power 32 49 100 + 10000000 powerful 32 49 100 + 10000000 practical 28 32 100 + 10000000 prim.abundant 70 368 464 + 9998574 prime 13 19 23 + 9999991 primeval 13 13679 102347 + 1003679 pronic 1122 1332 5112 + 9982440 Proth 13 49 97 + 9994241 pseudoperfect 28 100 176 + 1000000 rare 621770 repdigit 44 888 5555 + 2222222 repfigit 19 28 4788 7913837 repunit 13 31 91 + 9988761 Rhonda 4752 5824 8526 + 9322158 Ruth-Aaron 49 1330 1521 + 9867276 Saint-Exupery 12180 79860 118080 + 9903180 Sastry 2066115 self 31 86 97 + 9999976 semiprime 10 49 82 + 9999967 sliding 70 133 700 + 9775865 Smith 94 319 391 + 9999355 sphenic 70 130 190 + 9999983 square 49 100 784 + 9966649 star 13 793 937 + 9868837 straight-line 888 3456 5555 + 9876543 strobogrammatic 818 888 1881 + 9980866 strong prime 79 97 239 + 9999929 subfactorial 44 super Niven 10 70 100 + 10000000 super-d 19 31 190 + 9999919 superabundant 15120 55440 110880 + 2162160 tau 376 536 632 + 10000000 taxicab 110808 165464 195841 + 9443761 tetrahedral 10 680 1330 + 9962680 tetranacci 208 283953 1055026 7555935 triangular 10 28 91 + 9988215 tribonacci 13 44 trimorphic 49 376 8751 109376 truncatable prime 13 23 31 + 9973547 twin 13 19 31 + 9999929 uban 10 13 19 + 10000000 Ulam 13 28 82 + 9999760 undulating 262 313 383 + 8585858 unprimeable 208 320 326 + 10000000 untouchable 188 262 326 + 999928 upside-down 19 28 82 + 9955511 vampire 102510 105210 105264 + 829696 wasteful 28 44 68 + 9999992 weak prime 13 19 23 + 9999991 weakly prime 604171 3326489 5152507 + 8532761 weird 70 836 11410 + 997430 Wieferich 1093 10533 42627 + 684645 Woodall 23 383 15624 + 5764800 Zeisel 31929 54205 114985 + 8011459 Zuckerman 1112 1115 1184 + 9173115 Zumkeller 28 70 176 + 100000 zygodrome 44 888 1122 + 9998877