Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Happy number

From Wikipedia, the free encyclopedia
Numbers with a certain property involving recursive summation
Not to be confused withHarshad number (derived from Sanskritharśa meaning "great joy").

Tree showing all happy numbers up to 100, and 130
Sad numbers up to 100 showing the repeating cycle of 8 numbers

Innumber theory, ahappy number is a number which eventually reaches 1 when the number is replaced by the sum of the square of each digit. For instance, 13 is a happy number because12+32=10{\displaystyle 1^{2}+3^{2}=10}, and12+02=1{\displaystyle 1^{2}+0^{2}=1}. On the other hand, 4 is not a happy number because the sequence starting with42=16{\displaystyle 4^{2}=16} and12+62=37{\displaystyle 1^{2}+6^{2}=37} eventually reaches22+02=4{\displaystyle 2^{2}+0^{2}=4}, the number that started the sequence, and so the process continues in an infinite cycle without ever reaching 1.[1] A number which is not happy is calledsad orunhappy.

More generally, ab{\displaystyle b}-happy number is anatural number in a givennumber baseb{\displaystyle b} that eventually reaches 1 when iterated over theperfect digital invariant function forp=2{\displaystyle p=2}.[2]

The origin of happy numbers is not clear. Happy numbers were brought to the attention of Reginald Allenby (a British author and senior lecturer inpure mathematics atLeeds University) by his daughter, who had learned of them at school. However, they "may have originated in Russia."[3]

Happy numbers and perfect digital invariants

[edit]
See also:Perfect digital invariant

Formally, letn{\displaystyle n} be a natural number. Given theperfect digital invariant function

Fp,b(n)=i=0logbn(nmodbi+1nmodbibi)p{\displaystyle F_{p,b}(n)=\sum _{i=0}^{\lfloor \log _{b}{n}\rfloor }{\left({\frac {n{\bmod {b^{i+1}}}-n{\bmod {b^{i}}}}{b^{i}}}\right)}^{p}}.

for baseb>1{\displaystyle b>1}, a numbern{\displaystyle n} isb{\displaystyle b}-happy if there exists aj{\displaystyle j} such thatF2,bj(n)=1{\displaystyle F_{2,b}^{j}(n)=1}, whereF2,bj{\displaystyle F_{2,b}^{j}} represents thej{\displaystyle j}-thiteration ofF2,b{\displaystyle F_{2,b}}, andb{\displaystyle b}-unhappy otherwise. If a number is anontrivial perfect digital invariant ofF2,b{\displaystyle F_{2,b}}, then it isb{\displaystyle b}-unhappy.

For example, 19 is 10-happy, as

F2,10(19)=12+92=82{\displaystyle F_{2,10}(19)=1^{2}+9^{2}=82}
F2,102(19)=F2,10(82)=82+22=68{\displaystyle F_{2,10}^{2}(19)=F_{2,10}(82)=8^{2}+2^{2}=68}
F2,103(19)=F2,10(68)=62+82=100{\displaystyle F_{2,10}^{3}(19)=F_{2,10}(68)=6^{2}+8^{2}=100}
F2,104(19)=F2,10(100)=12+02+02=1{\displaystyle F_{2,10}^{4}(19)=F_{2,10}(100)=1^{2}+0^{2}+0^{2}=1}

For example, 347 is 6-happy, as

F2,6(347)=F2,6(13356)=12+32+32+52=44{\displaystyle F_{2,6}(347)=F_{2,6}(1335_{6})=1^{2}+3^{2}+3^{2}+5^{2}=44}
F2,62(347)=F2,6(44)=F2,6(1126)=12+12+22=6{\displaystyle F_{2,6}^{2}(347)=F_{2,6}(44)=F_{2,6}(112_{6})=1^{2}+1^{2}+2^{2}=6}
F2,63(347)=F2,6(6)=F2,6(106)=12+02=1{\displaystyle F_{2,6}^{3}(347)=F_{2,6}(6)=F_{2,6}(10_{6})=1^{2}+0^{2}=1}

There are infinitely manyb{\displaystyle b}-happy numbers, as 1 is ab{\displaystyle b}-happy number, and for everyn{\displaystyle n},bn{\displaystyle b^{n}} (10n{\displaystyle 10^{n}} in baseb{\displaystyle b}) isb{\displaystyle b}-happy, since its sum is 1. Thehappiness of a number is preserved by removing or inserting zeroes at will, since they do not contribute to the cross sum.

Natural density ofb-happy numbers

[edit]

By inspection of the first million or so 10-happy numbers, it appears that they have anatural density of around 0.15. Perhaps surprisingly, then, the 10-happy numbers do not have an asymptotic density. The upper density of the happy numbers is greater than 0.18577, and the lower density is less than 0.1138.[4]

Happy bases

[edit]
Unsolved problem in mathematics
Arebase 2 andbase 4 the only bases that are happy?
More unsolved problems in mathematics

A happy base is a number baseb{\displaystyle b} where every number isb{\displaystyle b}-happy. The only happy integer bases less than5×108 arebase 2 andbase 4.[5]

Specificb-happy numbers

[edit]

4-happy numbers

[edit]

Forb=4{\displaystyle b=4}, the only positive perfect digital invariant forF2,b{\displaystyle F_{2,b}} is the trivial perfect digital invariant 1, and there are no other cycles. Because all numbers arepreperiodic points forF2,b{\displaystyle F_{2,b}}, all numbers lead to 1 and are happy. As a result,base 4 is a happy base.

6-happy numbers

[edit]

Forb=6{\displaystyle b=6}, the only positive perfect digital invariant forF2,b{\displaystyle F_{2,b}} is the trivial perfect digital invariant 1, and the only cycle is the eight-number cycle

5 → 41 → 25 → 45 → 105 → 42 → 32 → 21 → 5 → ...

and because all numbers are preperiodic points forF2,b{\displaystyle F_{2,b}}, all numbers either lead to 1 and are happy, or lead to the cycle and are unhappy. Because base 6 has no other perfect digital invariants except for 1, no positive integer other than 1 is the sum of the squares of its own digits.

In base 10, the 74 6-happy numbers up to 1296 = 64 are (written in base 10):

1, 6, 36, 44, 49, 79, 100, 160, 170, 216, 224, 229, 254, 264, 275, 285, 289, 294, 335, 347, 355, 357, 388, 405, 415, 417, 439, 460, 469, 474, 533, 538, 580, 593, 600, 608, 628, 638, 647, 695, 707, 715, 717, 767, 777, 787, 835, 837, 847, 880, 890, 928, 940, 953, 960, 968, 1010, 1018, 1020, 1033, 1058, 1125, 1135, 1137, 1168, 1178, 1187, 1195, 1197, 1207, 1238, 1277, 1292, 1295

10-happy numbers

[edit]

Forb=10{\displaystyle b=10}, the only positive perfect digital invariant forF2,b{\displaystyle F_{2,b}} is the trivial perfect digital invariant 1, and the only cycle is the eight-number cycle

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

and because all numbers are preperiodic points forF2,b{\displaystyle F_{2,b}}, all numbers either lead to 1 and are happy, or lead to the cycle and are unhappy. Because base 10 has no other perfect digital invariants except for 1, no positive integer other than 1 is the sum of the squares of its own digits.

In base 10, the 143 10-happy numbers up to 1000 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, 193, 203, 208, 219, 226, 230, 236, 239, 262, 263, 280, 291, 293, 301, 302, 310, 313, 319, 320, 326, 329, 331, 338, 356, 362, 365, 367, 368, 376, 379, 383, 386, 391, 392, 397, 404, 409, 440, 446, 464, 469, 478, 487, 490, 496, 536, 556, 563, 565, 566, 608, 617, 622, 623, 632, 635, 637, 638, 644, 649, 653, 655, 656, 665, 671, 673, 680, 683, 694, 700, 709, 716, 736, 739, 748, 761, 763, 784, 790, 793, 802, 806, 818, 820, 833, 836, 847, 860, 863, 874, 881, 888, 899, 901, 904, 907, 910, 912, 913, 921, 923, 931, 932, 937, 940, 946, 964, 970, 973, 989, 998, 1000 (sequenceA007770 in theOEIS).

The distinct combinations of digits that form 10-happy numbers below 1000 are (the rest are just rearrangements and/or insertions of zero digits):

1, 7, 13, 19, 23, 28, 44, 49, 68, 79, 129, 133, 139, 167, 188, 226, 236, 239, 338, 356, 367, 368, 379, 446, 469, 478, 556, 566, 888, 899. (sequenceA124095 in theOEIS).

The first pair of consecutive 10-happy numbers is 31 and 32.[6] The first set of three consecutive is 1880, 1881, and 1882.[7] It has been proven that there exist sequences of consecutive happy numbers of any natural number length.[8] The beginning of the first run of at leastn consecutive 10-happy numbers forn = 1, 2, 3, ... is[9]

1, 31, 1880, 7839, 44488, 7899999999999959999999996, 7899999999999959999999996, ...

As Robert Styer puts it in his paper calculating this series: "Amazingly, the same value of N that begins the least sequence of six consecutive happy numbers also begins the least sequence of seven consecutive happy numbers."[10]

The number of 10-happy numbers up to 10n for 1 ≤ n ≤ 20 is[11]

3, 20, 143, 1442, 14377, 143071, 1418854, 14255667, 145674808, 1492609148, 15091199357, 149121303586, 1443278000870, 13770853279685, 130660965862333, 1245219117260664, 12024696404768025, 118226055080025491, 1183229962059381238, 12005034444292997294.

Happy primes

[edit]

Ab{\displaystyle b}-happy prime is a number that is bothb{\displaystyle b}-happy andprime. Unlike happy numbers, rearranging the digits of ab{\displaystyle b}-happy prime will not necessarily create another happy prime. For instance, while 19 is a 10-happy prime, 91 = 13 × 7 is not prime (but is still 10-happy).

All prime numbers are 2-happy and 4-happy primes, asbase 2 andbase 4 are happy bases.

6-happy primes

[edit]

Inbase 6, the 6-happy primes below 1296 = 64 are

211, 1021, 1335, 2011, 2425, 2555, 3351, 4225, 4441, 5255, 5525

10-happy primes

[edit]

Inbase 10, the 10-happy primes below 500 are

7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239, 263, 293, 313, 331, 367, 379, 383, 397, 409, 487 (sequenceA035497 in theOEIS).

Thepalindromic prime10150006 +7426247×1075000 + 1 is a 10-happy prime with150007 digits because the many 0s do not contribute to the sum of squared digits, and12 + 72 + 42 + 22 + 62 + 22 + 42 + 72 + 12 = 176, which is a 10-happy number. Paul Jobling discovered the prime in 2005.[12]

As of 2010[update], the largest known 10-happy prime is 242643801 − 1 (aMersenne prime).[dubiousdiscuss] Its decimal expansion has12837064 digits.[13]

12-happy primes

[edit]

Inbase 12, there are no 12-happy primes less than 10000, the first 12-happy primes are (the letters X and E represent the decimal numbers 10 and 11 respectively)

11031, 1233E, 13011, 1332E, 16377, 17367, 17637, 22E8E, 2331E, 233E1, 23955, 25935, 25X8E, 28X5E, 28XE5, 2X8E5, 2E82E, 2E8X5, 31011, 31101, 3123E, 3132E, 31677, 33E21, 35295, 35567, 35765, 35925, 36557, 37167, 37671, 39525, 4878E, 4X7X7, 53567, 55367, 55637, 56357, 57635, 58XX5, 5X82E, 5XX85, 606EE, 63575, 63771, 66E0E, 67317, 67371, 67535, 6E60E, 71367, 71637, 73167, 76137, 7XX47, 82XE5, 82EX5, 8487E, 848E7, 84E87, 8874E, 8X1X7, 8X25E, 8X2E5, 8X5X5, 8XX17, 8XX71, 8E2X5, 8E847, 92355, 93255, 93525, 95235, X1X87, X258E, X285E, X2E85, X85X5, X8X17, XX477, XX585, E228E, E606E, E822E, EX825, ...

Programming example

[edit]

The examples below implement the perfect digital invariant function forp=2{\displaystyle p=2} and a default baseb=10{\displaystyle b=10} described in the definition of happy given at the top of this article, repeatedly; after each time, they check for both halt conditions: reaching 1, andrepeating a number.

A simple test inPython to check if a number is happy:

defpdi_function(number,base:int=10):"""Perfect digital invariant function."""total=0whilenumber>0:total+=pow(number%base,2)number=number//basereturntotaldefis_happy(number:int)->bool:"""Determine if the specified number is a happy number."""seen_numbers=set()whilenumber>1andnumbernotinseen_numbers:seen_numbers.add(number)number=pdi_function(number)returnnumber==1

In popular culture

[edit]
  • In 2007, the concept of happy numbers was used inProfessor Layton and the Diabolical Box, in puzzle 149 ("Number Cycle"), using the sequence beginning with 4, which repeats every 8 terms.
  • In theDoctor Who episode42, a sequence of happy primes is the password to open a door.

See also

[edit]

References

[edit]
  1. ^Honsberger, Ross (1970).Ingenuity in mathematics. New mathematical library. New York: The Mathematical association of America. pp. 83–84.ISBN 978-0-88385-623-9.
  2. ^"Sad Number". Wolfram Research, Inc. Retrieved16 September 2009.
  3. ^Guy, Richard K. (13 July 2004).Unsolved problems in number theory. Problem books in mathematics (3rd ed.). New York: Springer. pp. 357–358.ISBN 978-0-387-20860-2.
  4. ^Gilmer, Justin (2013). "On the Density of Happy Numbers".Integers.13 (2): 2.arXiv:1110.3836.Bibcode:2011arXiv1110.3836G.
  5. ^Sloane, N. J. A. (ed.)."Sequence A161872 (Smallest unhappy number in base n)".TheOn-Line Encyclopedia of Integer Sequences. OEIS Foundation.
  6. ^Sloane, N. J. A. (ed.)."Sequence A035502 (Lower of pair of consecutive happy numbers)".TheOn-Line Encyclopedia of Integer Sequences. OEIS Foundation. Retrieved8 April 2011.
  7. ^Sloane, N. J. A. (ed.)."Sequence A072494 (First of triples of consecutive happy numbers)".TheOn-Line Encyclopedia of Integer Sequences. OEIS Foundation. Retrieved8 April 2011.
  8. ^Pan, Hao (2006). "Consecutive Happy Numbers".arXiv:math/0607213.
  9. ^Sloane, N. J. A. (ed.)."Sequence A055629 (Beginning of first run of at leastn consecutive happy numbers)".TheOn-Line Encyclopedia of Integer Sequences. OEIS Foundation.
  10. ^Styer, Robert (2010)."Smallest Examples of Strings of Consecutive Happy Numbers".Journal of Integer Sequences.13: 5. 10.6.3 – viaUniversity of Waterloo. Cited inSloane "A055629" harvtxt error: no target: CITEREFSloane_"A055629" (help).
  11. ^Sloane, N. J. A. (ed.)."Sequence A068571 (Number of happy numbers <= 10^n)".TheOn-Line Encyclopedia of Integer Sequences. OEIS Foundation.
  12. ^Chris K. Caldwell."The Prime Database: 10150006 + 7426247 · 1075000 + 1".utm.edu.
  13. ^Chris K. Caldwell."The Prime Database: 242643801 − 1".utm.edu.

External links

[edit]
Classes ofnatural numbers
Powers and related numbers
Of the forma × 2b ± 1
Other polynomial numbers
Recursively defined numbers
Possessing a specific set of other numbers
Expressible via specific sums
2-dimensional
centered
non-centered
3-dimensional
centered
non-centered
pyramidal
4-dimensional
non-centered
Combinatorial numbers
Divisor functions
Prime omega functions
Euler's totient function
Aliquot sequences
Primorial
Otherprime factor ordivisor related numbers
Numeral system-dependent numbers
Arithmetic functions
anddynamics
Digit sum
Digit product
Coding-related
Other
P-adic numbers-related
Digit-composition related
Digit-permutation related
Divisor-related
Other
Generated via asieve
Sorting related
Graphemics related
Prime number classes
By formula
By integer sequence
By property
Base-dependent
Patterns
k-tuples
By size
Complex numbers
Composite numbers
Related topics
First 60 primes
Retrieved from "https://en.wikipedia.org/w/index.php?title=Happy_number&oldid=1332704148"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp