Jump to content

Edit filter log

Details for log entry 31711400

22:31, 16 January 2022: 213.137.65.213 (talk) triggered filter 636, performing the action "edit" on Happy number. Actions taken: Warn; Filter description: Unexplained removal of sourced content (examine)

Changes made in edit



The origin of happy numbers is not clear. Happy numbers were brought to the attention of [[Reg Allenby]] (a British author and senior lecturer in [[pure mathematics]] at [[Leeds University]]) by his daughter, who had learned of them at school. However, they "may have originated in Russia" {{harvcol|Guy|2004|p=§E34}}.
The origin of happy numbers is not clear. Happy numbers were brought to the attention of [[Reg Allenby]] (a British author and senior lecturer in [[pure mathematics]] at [[Leeds University]]) by his daughter, who had learned of them at school. However, they "may have originated in Russia" {{harvcol|Guy|2004|p=§E34}}.

== Happy numbers and perfect digital invariants ==
{{See also|Perfect digital invariant}}
Formally, let <math>n</math> be a natural number. Given the [[Perfect digital invariant|perfect digital invariant function]]
:<math>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</math>.
for base <math>b > 1</math>, a number <math>n</math> is <math>b</math>-happy if there exists a <math>j</math> such that <math>F_{2, b}^j(n) = 1</math>, where <math>F_{2, b}^j</math> represents the <math>j</math>-th [[Iterated function|iteration]] of <math>F_{2, b}</math>, and <math>b</math>-unhappy otherwise. If a number is a [[#Perfect digital invariant|nontrivial perfect digital invariant]] of <math>F_{2, b}</math>, then it is <math>b</math>-unhappy.

For example, 19 is 10-happy, as
: <math>F_{2, 10}(19) = 1^2 + 9^2 = 82</math>
: <math>F_{2, 10}^2(19) = F_{2, 10}(82) = 8^2 + 2^2 = 68</math>
: <math>F_{2, 10}^3(19) = F_{2, 10}(68) = 6^2 + 8^2 = 100</math>
: <math>F_{2, 10}^4(19) = F_{2, 10}(100) = 1^2 + 0^2 + 0^2 = 1</math>

For example, 347 is 6-happy, as
: <math>F_{2, 6}(347) = F_{2, 6}(1335_6) = 1^2 + 3^2 + 3^2 + 5^2 = 44</math>
: <math>F_{2, 6}^2(347) = F_{2, 6}(44) = F_{2, 6}(112_6) = 1^2 + 1^2 + 2^2 = 6</math>
: <math>F_{2, 6}^3(347) = F_{2, 6}(6) = F_{2, 6}(10_6) = 1^2 + 0^2 = 1</math>

There are infinitely many <math>b</math>-happy numbers, as 1 is a <math>b</math>-happy number, and for every <math>n</math>, <math>b^n</math> (<math>10^n</math> in base <math>b</math>) is <math>b</math>-happy, since its sum is 1. The ''happiness'' of a number is preserved by removing or inserting zeroes at will, since they do not contribute to the cross sum.

=== Natural density of ''b''-happy numbers ===
By inspection of the first million or so 10-happy numbers, it appears that they have a [[natural 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.<ref>{{Cite journal |title=On the Density of Happy Numbers |journal=Integers |volume=13 |issue=2 |arxiv=1110.3836 |last1=Gilmer |first1=Justin |year=2011 |bibcode=2011arXiv1110.3836G}}</ref>

=== Happy bases ===
{{unsolved|mathematics|Are [[base 2]] and [[base 4]] the only bases that are happy?}}
A happy base is a number base <math>b</math> where every number is <math>b</math>-happy. The only happy bases less than {{val|5e8}} are [[base 2]] and [[base 4]].<ref>{{Cite OEIS|sequencenumber=A161872|name=Smallest unhappy number in base n}}</ref>


==Specific ''b''-happy numbers==
==Specific ''b''-happy numbers==

Action parameters

VariableValue
Edit count of the user (user_editcount)
null
Name of the user account (user_name)
'213.137.65.213'
Age of the user account (user_age)
0
Groups (including implicit) the user is in (user_groups)
[ 0 => '*' ]
Rights that the user has (user_rights)
[ 0 => 'createaccount', 1 => 'read', 2 => 'edit', 3 => 'createtalk', 4 => 'writeapi', 5 => 'viewmywatchlist', 6 => 'editmywatchlist', 7 => 'viewmyprivateinfo', 8 => 'editmyprivateinfo', 9 => 'editmyoptions', 10 => 'abusefilter-log-detail', 11 => 'urlshortener-create-url', 12 => 'centralauth-merge', 13 => 'abusefilter-view', 14 => 'abusefilter-log', 15 => 'vipsscaler-test' ]
Whether the user is editing from mobile app (user_app)
true
Whether or not a user is editing through the mobile interface (user_mobile)
false
Page ID (page_id)
542994
Page namespace (page_namespace)
0
Page title without namespace (page_title)
'Happy number'
Full page title (page_prefixedtitle)
'Happy number'
Edit protection level of the page (page_restrictions_edit)
[]
Last ten users to contribute to the page (page_recent_contributors)
[ 0 => 'SCP-2000', 1 => '223.16.222.9', 2 => 'PrimeHunter', 3 => 'TwoTwoHello', 4 => '182.64.35.0', 5 => 'DavidWBrooks', 6 => '72.48.59.139', 7 => 'Yamaguchi先生', 8 => '2409:4043:387:9A43:0:0:230C:88B0', 9 => '193.33.3.228' ]
Page age in seconds (page_age)
562456297
Action (action)
'edit'
Edit summary/reason (summary)
'/* Happy numbers and perfect digital invariants */ '
Old content model (old_content_model)
'wikitext'
New content model (new_content_model)
'wikitext'
Old page wikitext, before the edit (old_wikitext)
'{{short description|Numbers with a certain property involving recursive summation}} {{distinguish|text=[[Harshad number]] (derived from Sanskrit ''harśa'' meaning "great joy")}} {{Use dmy dates|date=October 2020}} In [[number theory]], a '''happy number''' is a number which eventually reaches 1 when replaced by the sum of the square of each digit. For instance, 13 is a happy number because <math>1^2+3^2=10</math>, and <math>1^2+0^2=1</math>. On the other hand, 4 is not a happy number because the sequence starting with <math>4^2=16</math> and <math>1^2+6^2=37</math> eventually reaches <math>2^2+0^2=4</math>, the number that started the sequence, and so the process continues in an infinite cycle without ever reaching 1. A number which is not happy is called '''sad''' or '''unhappy'''. More generally, a <math>b</math>-'''happy number''' is a [[natural number]] in a given [[number base]] <math>b</math> that eventually reaches 1 when iterated over the [[Perfect digital invariant|perfect digital invariant function]] for <math>p = 2</math>.<ref>{{cite web|url=http://mathworld.wolfram.com/SadNumber.html|title=Sad Number|publisher=Wolfram Research, Inc.|access-date=2009-09-16}}</ref> The origin of happy numbers is not clear. Happy numbers were brought to the attention of [[Reg Allenby]] (a British author and senior lecturer in [[pure mathematics]] at [[Leeds University]]) by his daughter, who had learned of them at school. However, they "may have originated in Russia" {{harvcol|Guy|2004|p=§E34}}. == Happy numbers and perfect digital invariants == {{See also|Perfect digital invariant}} Formally, let <math>n</math> be a natural number. Given the [[Perfect digital invariant|perfect digital invariant function]] :<math>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</math>. for base <math>b > 1</math>, a number <math>n</math> is <math>b</math>-happy if there exists a <math>j</math> such that <math>F_{2, b}^j(n) = 1</math>, where <math>F_{2, b}^j</math> represents the <math>j</math>-th [[Iterated function|iteration]] of <math>F_{2, b}</math>, and <math>b</math>-unhappy otherwise. If a number is a [[#Perfect digital invariant|nontrivial perfect digital invariant]] of <math>F_{2, b}</math>, then it is <math>b</math>-unhappy. For example, 19 is 10-happy, as : <math>F_{2, 10}(19) = 1^2 + 9^2 = 82</math> : <math>F_{2, 10}^2(19) = F_{2, 10}(82) = 8^2 + 2^2 = 68</math> : <math>F_{2, 10}^3(19) = F_{2, 10}(68) = 6^2 + 8^2 = 100</math> : <math>F_{2, 10}^4(19) = F_{2, 10}(100) = 1^2 + 0^2 + 0^2 = 1</math> For example, 347 is 6-happy, as : <math>F_{2, 6}(347) = F_{2, 6}(1335_6) = 1^2 + 3^2 + 3^2 + 5^2 = 44</math> : <math>F_{2, 6}^2(347) = F_{2, 6}(44) = F_{2, 6}(112_6) = 1^2 + 1^2 + 2^2 = 6</math> : <math>F_{2, 6}^3(347) = F_{2, 6}(6) = F_{2, 6}(10_6) = 1^2 + 0^2 = 1</math> There are infinitely many <math>b</math>-happy numbers, as 1 is a <math>b</math>-happy number, and for every <math>n</math>, <math>b^n</math> (<math>10^n</math> in base <math>b</math>) is <math>b</math>-happy, since its sum is 1. The ''happiness'' of a number is preserved by removing or inserting zeroes at will, since they do not contribute to the cross sum. === Natural density of ''b''-happy numbers === By inspection of the first million or so 10-happy numbers, it appears that they have a [[natural 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.<ref>{{Cite journal |title=On the Density of Happy Numbers |journal=Integers |volume=13 |issue=2 |arxiv=1110.3836 |last1=Gilmer |first1=Justin |year=2011 |bibcode=2011arXiv1110.3836G}}</ref> === Happy bases === {{unsolved|mathematics|Are [[base 2]] and [[base 4]] the only bases that are happy?}} A happy base is a number base <math>b</math> where every number is <math>b</math>-happy. The only happy bases less than {{val|5e8}} are [[base 2]] and [[base 4]].<ref>{{Cite OEIS|sequencenumber=A161872|name=Smallest unhappy number in base n}}</ref> ==Specific ''b''-happy numbers== ===4-happy numbers=== For <math>b = 4</math>, the only positive perfect digital invariant for <math>F_{2, b}</math> is the trivial perfect digital invariant 1, and there are no other cycles. Because all numbers are [[Periodic point#Iterated functions|preperiodic points]] for <math>F_{2, b}</math>, all numbers lead to 1 and are happy. As a result, [[base 4]] is a happy base. ===6-happy numbers=== For <math>b = 6</math>, the only positive perfect digital invariant for <math>F_{2, b}</math> 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 for <math>F_{2, b}</math>, 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 = 6<sup>4</sup> 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=== For <math>b = 10</math>, the only positive perfect digital invariant for <math>F_{2, b}</math> 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 for <math>F_{2, b}</math>, 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 {{OEIS|id=A007770}}. 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. {{OEIS|id=A124095}}. The first pair of consecutive 10-happy numbers is 31 and 32.<ref>{{cite OEIS |1=A035502 |2=Lower of pair of consecutive happy numbers |access-date=8 April 2011}}</ref> The first set of three consecutive is 1880, 1881, and 1882.<ref>{{cite OEIS |1=A072494 |2=First of triples of consecutive happy numbers |access-date=8 April 2011}}</ref> It has been proven that there exist sequences of consecutive happy numbers of any natural number length.<ref>{{Cite arxiv |title=Consecutive Happy Numbers |arxiv=math/0607213 |author1=Pan |first1=Hao |year=2006}}</ref> The beginning of the first run of at least ''n'' consecutive 10-happy numbers for ''n''&nbsp;=&thinsp;1, 2, 3, ... is<ref name="Sloane-A055629">{{Cite OEIS |1=A055629 |2=Beginning of first run of at least ''n'' consecutive happy numbers}}</ref> : 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."<ref>{{cite journal |last=Styer |first=Robert |year=2010 |page=5 |title=Smallest Examples of Strings of Consecutive Happy Numbers |journal=[[Journal of Integer Sequences]] |volume=13 |id=10.6.3 |url=https://cs.uwaterloo.ca/journals/JIS/VOL13/Styer/styer5.html |via=[[University of Waterloo]]}} Cited in {{harvtxt|Sloane "A055629"}}.</ref> The number of 10-happy numbers up to 10<sup>''n''</sup> for 1&nbsp;≤&nbsp;''n''&nbsp;≤&nbsp;20 is<ref>{{Cite OEIS |1=A068571 |2=Number of happy numbers <= 10^n}}</ref> : 3, 20, 143, 1442, 14377, 143071, 1418854, 14255667, 145674808, 1492609148, 15091199357, 149121303586, 1443278000870, 13770853279685, 130660965862333, 1245219117260664, 12024696404768025, 118226055080025491, 1183229962059381238, 12005034444292997294. ==Happy primes== A <math>b</math>-happy prime is a number that is both <math>b</math>-happy and [[prime number|prime]]. Unlike happy numbers, rearranging the digits of a <math>b</math>-happy prime will not necessarily create another happy prime. For instance, while 19 is a 10-happy prime, 91&nbsp;=&nbsp;13&nbsp;×&nbsp;7 is not prime (but is still 10-happy). All prime numbers are 2-happy and 4-happy primes, as [[base 2]] and [[base 4]] are happy bases. ===6-happy primes=== In [[base 6]], the 6-happy primes below 1296 = 6<sup>4</sup> are :211, 1021, 1335, 2011, 2425, 2555, 3351, 4225, 4441, 5255, 5525 ===10-happy primes=== In [[base 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 {{OEIS|id=A035497}}. The [[palindromic prime]] {{nowrap|10<sup>150006</sup> + {{val|7426247e75000}} + 1}} is a 10-happy prime with {{val|150,007}} digits because the many 0s do not contribute to the sum of squared digits, and {{nowrap|1<sup>2</sup> + 7<sup>2</sup> + 4<sup>2</sup> + 2<sup>2</sup> + 6<sup>2</sup> + 2<sup>2</sup> + 4<sup>2</sup> + 7<sup>2</sup> + 1<sup>2</sup>}} =&nbsp;176, which is a 10-happy number. Paul Jobling discovered the prime in 2005.<ref>{{cite web |url=http://primes.utm.edu/primes/page.php?id=76550 |title=The Prime Database: 10<sup>150006</sup> + 7426247 · 10<sup>75000</sup> + 1 |author=Chris K. Caldwell |work=utm.edu}}</ref> {{As of|2010}}, the largest known 10-happy prime is 2<sup>42643801</sup>&nbsp;−&nbsp;1 (a [[Mersenne prime]]).{{Dubious|date=December 2017}} Its decimal expansion has {{val|12,837,064}} digits.<ref>{{cite web |url=http://primes.utm.edu/primes/page.php?id=88847 |title=The Prime Database: 2<sup>42643801</sup> − 1 |author=Chris K. Caldwell |work=utm.edu}}</ref> ===12-happy primes=== In [[base 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== The examples below implement the perfect digital invariant function for <math>p = 2</math> and a default base <math>b = 10</math> 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, and [[Cycle detection|repeating a number]]. A simple test in [[Python (programming language)|Python]] to check if a number is happy: <syntaxhighlight lang="python"> def pdi_function(number, base: int = 10): """Perfect digital invariant function.""" total = 0 while number > 0: total += pow(number % base, 2) number = number // base return total def is_happy(number: int) -> bool: """Determine if the specified number is a happy number.""" seen_numbers = set() while number > 1 and number not in seen_numbers: seen_numbers.add(number) number = pdi_function(number) return number == 1 </syntaxhighlight> ==See also== * [[Arithmetic dynamics#Other areas in which number theory and dynamics interact|Arithmetic dynamics]] *[[Fortunate number]] *[[Harshad number]] *[[Lucky number]] *[[Perfect digital invariant]] ==References== {{reflist}} ==Literature== * {{Cite book | last = Guy | first = Richard | author-link = Richard K. Guy | year = 2004 | title = Unsolved Problems in Number Theory |edition=3rd | publisher = [[Springer-Verlag]] | isbn= 0-387-20860-7 }} ==External links== * Schneider, Walter: [https://web.archive.org/web/20060204094653/http://www.wschnei.de/digit-related-numbers/happy-numbers.html Mathews: Happy Numbers.] * {{MathWorld|urlname=HappyNumber|title=Happy Number}} * [http://nazgul04.ddns.net/happy/happy.php calculate if a number is happy] * [http://mathforum.org/library/drmath/view/55856.html Happy Numbers] at The Math Forum. * [https://web.archive.org/web/20180703133816/http://numberphile.com/videos/melancoil.html 145 and the Melancoil] at Numberphile. * {{cite web|last=Symonds|first=Ria|title=7 and Happy Numbers|url=http://www.numberphile.com/videos/7happy.html|work=Numberphile|publisher=[[Brady Haran]]|access-date=2 April 2013|archive-url=https://web.archive.org/web/20180115215406/http://www.numberphile.com/videos/7happy.html|archive-date=15 January 2018|url-status=dead}} {{Classes of natural numbers}} {{Prime number classes}} {{DEFAULTSORT:Happy Number}} [[Category:Arithmetic dynamics]] [[Category:Base-dependent integer sequences]]'
New page wikitext, after the edit (new_wikitext)
'{{short description|Numbers with a certain property involving recursive summation}} {{distinguish|text=[[Harshad number]] (derived from Sanskrit ''harśa'' meaning "great joy")}} {{Use dmy dates|date=October 2020}} In [[number theory]], a '''happy number''' is a number which eventually reaches 1 when replaced by the sum of the square of each digit. For instance, 13 is a happy number because <math>1^2+3^2=10</math>, and <math>1^2+0^2=1</math>. On the other hand, 4 is not a happy number because the sequence starting with <math>4^2=16</math> and <math>1^2+6^2=37</math> eventually reaches <math>2^2+0^2=4</math>, the number that started the sequence, and so the process continues in an infinite cycle without ever reaching 1. A number which is not happy is called '''sad''' or '''unhappy'''. More generally, a <math>b</math>-'''happy number''' is a [[natural number]] in a given [[number base]] <math>b</math> that eventually reaches 1 when iterated over the [[Perfect digital invariant|perfect digital invariant function]] for <math>p = 2</math>.<ref>{{cite web|url=http://mathworld.wolfram.com/SadNumber.html|title=Sad Number|publisher=Wolfram Research, Inc.|access-date=2009-09-16}}</ref> The origin of happy numbers is not clear. Happy numbers were brought to the attention of [[Reg Allenby]] (a British author and senior lecturer in [[pure mathematics]] at [[Leeds University]]) by his daughter, who had learned of them at school. However, they "may have originated in Russia" {{harvcol|Guy|2004|p=§E34}}. ==Specific ''b''-happy numbers== ===4-happy numbers=== For <math>b = 4</math>, the only positive perfect digital invariant for <math>F_{2, b}</math> is the trivial perfect digital invariant 1, and there are no other cycles. Because all numbers are [[Periodic point#Iterated functions|preperiodic points]] for <math>F_{2, b}</math>, all numbers lead to 1 and are happy. As a result, [[base 4]] is a happy base. ===6-happy numbers=== For <math>b = 6</math>, the only positive perfect digital invariant for <math>F_{2, b}</math> 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 for <math>F_{2, b}</math>, 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 = 6<sup>4</sup> 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=== For <math>b = 10</math>, the only positive perfect digital invariant for <math>F_{2, b}</math> 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 for <math>F_{2, b}</math>, 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 {{OEIS|id=A007770}}. 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. {{OEIS|id=A124095}}. The first pair of consecutive 10-happy numbers is 31 and 32.<ref>{{cite OEIS |1=A035502 |2=Lower of pair of consecutive happy numbers |access-date=8 April 2011}}</ref> The first set of three consecutive is 1880, 1881, and 1882.<ref>{{cite OEIS |1=A072494 |2=First of triples of consecutive happy numbers |access-date=8 April 2011}}</ref> It has been proven that there exist sequences of consecutive happy numbers of any natural number length.<ref>{{Cite arxiv |title=Consecutive Happy Numbers |arxiv=math/0607213 |author1=Pan |first1=Hao |year=2006}}</ref> The beginning of the first run of at least ''n'' consecutive 10-happy numbers for ''n''&nbsp;=&thinsp;1, 2, 3, ... is<ref name="Sloane-A055629">{{Cite OEIS |1=A055629 |2=Beginning of first run of at least ''n'' consecutive happy numbers}}</ref> : 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."<ref>{{cite journal |last=Styer |first=Robert |year=2010 |page=5 |title=Smallest Examples of Strings of Consecutive Happy Numbers |journal=[[Journal of Integer Sequences]] |volume=13 |id=10.6.3 |url=https://cs.uwaterloo.ca/journals/JIS/VOL13/Styer/styer5.html |via=[[University of Waterloo]]}} Cited in {{harvtxt|Sloane "A055629"}}.</ref> The number of 10-happy numbers up to 10<sup>''n''</sup> for 1&nbsp;≤&nbsp;''n''&nbsp;≤&nbsp;20 is<ref>{{Cite OEIS |1=A068571 |2=Number of happy numbers <= 10^n}}</ref> : 3, 20, 143, 1442, 14377, 143071, 1418854, 14255667, 145674808, 1492609148, 15091199357, 149121303586, 1443278000870, 13770853279685, 130660965862333, 1245219117260664, 12024696404768025, 118226055080025491, 1183229962059381238, 12005034444292997294. ==Happy primes== A <math>b</math>-happy prime is a number that is both <math>b</math>-happy and [[prime number|prime]]. Unlike happy numbers, rearranging the digits of a <math>b</math>-happy prime will not necessarily create another happy prime. For instance, while 19 is a 10-happy prime, 91&nbsp;=&nbsp;13&nbsp;×&nbsp;7 is not prime (but is still 10-happy). All prime numbers are 2-happy and 4-happy primes, as [[base 2]] and [[base 4]] are happy bases. ===6-happy primes=== In [[base 6]], the 6-happy primes below 1296 = 6<sup>4</sup> are :211, 1021, 1335, 2011, 2425, 2555, 3351, 4225, 4441, 5255, 5525 ===10-happy primes=== In [[base 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 {{OEIS|id=A035497}}. The [[palindromic prime]] {{nowrap|10<sup>150006</sup> + {{val|7426247e75000}} + 1}} is a 10-happy prime with {{val|150,007}} digits because the many 0s do not contribute to the sum of squared digits, and {{nowrap|1<sup>2</sup> + 7<sup>2</sup> + 4<sup>2</sup> + 2<sup>2</sup> + 6<sup>2</sup> + 2<sup>2</sup> + 4<sup>2</sup> + 7<sup>2</sup> + 1<sup>2</sup>}} =&nbsp;176, which is a 10-happy number. Paul Jobling discovered the prime in 2005.<ref>{{cite web |url=http://primes.utm.edu/primes/page.php?id=76550 |title=The Prime Database: 10<sup>150006</sup> + 7426247 · 10<sup>75000</sup> + 1 |author=Chris K. Caldwell |work=utm.edu}}</ref> {{As of|2010}}, the largest known 10-happy prime is 2<sup>42643801</sup>&nbsp;−&nbsp;1 (a [[Mersenne prime]]).{{Dubious|date=December 2017}} Its decimal expansion has {{val|12,837,064}} digits.<ref>{{cite web |url=http://primes.utm.edu/primes/page.php?id=88847 |title=The Prime Database: 2<sup>42643801</sup> − 1 |author=Chris K. Caldwell |work=utm.edu}}</ref> ===12-happy primes=== In [[base 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== The examples below implement the perfect digital invariant function for <math>p = 2</math> and a default base <math>b = 10</math> 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, and [[Cycle detection|repeating a number]]. A simple test in [[Python (programming language)|Python]] to check if a number is happy: <syntaxhighlight lang="python"> def pdi_function(number, base: int = 10): """Perfect digital invariant function.""" total = 0 while number > 0: total += pow(number % base, 2) number = number // base return total def is_happy(number: int) -> bool: """Determine if the specified number is a happy number.""" seen_numbers = set() while number > 1 and number not in seen_numbers: seen_numbers.add(number) number = pdi_function(number) return number == 1 </syntaxhighlight> ==See also== * [[Arithmetic dynamics#Other areas in which number theory and dynamics interact|Arithmetic dynamics]] *[[Fortunate number]] *[[Harshad number]] *[[Lucky number]] *[[Perfect digital invariant]] ==References== {{reflist}} ==Literature== * {{Cite book | last = Guy | first = Richard | author-link = Richard K. Guy | year = 2004 | title = Unsolved Problems in Number Theory |edition=3rd | publisher = [[Springer-Verlag]] | isbn= 0-387-20860-7 }} ==External links== * Schneider, Walter: [https://web.archive.org/web/20060204094653/http://www.wschnei.de/digit-related-numbers/happy-numbers.html Mathews: Happy Numbers.] * {{MathWorld|urlname=HappyNumber|title=Happy Number}} * [http://nazgul04.ddns.net/happy/happy.php calculate if a number is happy] * [http://mathforum.org/library/drmath/view/55856.html Happy Numbers] at The Math Forum. * [https://web.archive.org/web/20180703133816/http://numberphile.com/videos/melancoil.html 145 and the Melancoil] at Numberphile. * {{cite web|last=Symonds|first=Ria|title=7 and Happy Numbers|url=http://www.numberphile.com/videos/7happy.html|work=Numberphile|publisher=[[Brady Haran]]|access-date=2 April 2013|archive-url=https://web.archive.org/web/20180115215406/http://www.numberphile.com/videos/7happy.html|archive-date=15 January 2018|url-status=dead}} {{Classes of natural numbers}} {{Prime number classes}} {{DEFAULTSORT:Happy Number}} [[Category:Arithmetic dynamics]] [[Category:Base-dependent integer sequences]]'
Unified diff of changes made by edit (edit_diff)
'@@ -7,30 +7,4 @@ The origin of happy numbers is not clear. Happy numbers were brought to the attention of [[Reg Allenby]] (a British author and senior lecturer in [[pure mathematics]] at [[Leeds University]]) by his daughter, who had learned of them at school. However, they "may have originated in Russia" {{harvcol|Guy|2004|p=§E34}}. - -== Happy numbers and perfect digital invariants == -{{See also|Perfect digital invariant}} -Formally, let <math>n</math> be a natural number. Given the [[Perfect digital invariant|perfect digital invariant function]] -:<math>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</math>. -for base <math>b > 1</math>, a number <math>n</math> is <math>b</math>-happy if there exists a <math>j</math> such that <math>F_{2, b}^j(n) = 1</math>, where <math>F_{2, b}^j</math> represents the <math>j</math>-th [[Iterated function|iteration]] of <math>F_{2, b}</math>, and <math>b</math>-unhappy otherwise. If a number is a [[#Perfect digital invariant|nontrivial perfect digital invariant]] of <math>F_{2, b}</math>, then it is <math>b</math>-unhappy. - -For example, 19 is 10-happy, as -: <math>F_{2, 10}(19) = 1^2 + 9^2 = 82</math> -: <math>F_{2, 10}^2(19) = F_{2, 10}(82) = 8^2 + 2^2 = 68</math> -: <math>F_{2, 10}^3(19) = F_{2, 10}(68) = 6^2 + 8^2 = 100</math> -: <math>F_{2, 10}^4(19) = F_{2, 10}(100) = 1^2 + 0^2 + 0^2 = 1</math> - -For example, 347 is 6-happy, as -: <math>F_{2, 6}(347) = F_{2, 6}(1335_6) = 1^2 + 3^2 + 3^2 + 5^2 = 44</math> -: <math>F_{2, 6}^2(347) = F_{2, 6}(44) = F_{2, 6}(112_6) = 1^2 + 1^2 + 2^2 = 6</math> -: <math>F_{2, 6}^3(347) = F_{2, 6}(6) = F_{2, 6}(10_6) = 1^2 + 0^2 = 1</math> - -There are infinitely many <math>b</math>-happy numbers, as 1 is a <math>b</math>-happy number, and for every <math>n</math>, <math>b^n</math> (<math>10^n</math> in base <math>b</math>) is <math>b</math>-happy, since its sum is 1. The ''happiness'' of a number is preserved by removing or inserting zeroes at will, since they do not contribute to the cross sum. - -=== Natural density of ''b''-happy numbers === -By inspection of the first million or so 10-happy numbers, it appears that they have a [[natural 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.<ref>{{Cite journal |title=On the Density of Happy Numbers |journal=Integers |volume=13 |issue=2 |arxiv=1110.3836 |last1=Gilmer |first1=Justin |year=2011 |bibcode=2011arXiv1110.3836G}}</ref> - -=== Happy bases === -{{unsolved|mathematics|Are [[base 2]] and [[base 4]] the only bases that are happy?}} -A happy base is a number base <math>b</math> where every number is <math>b</math>-happy. The only happy bases less than {{val|5e8}} are [[base 2]] and [[base 4]].<ref>{{Cite OEIS|sequencenumber=A161872|name=Smallest unhappy number in base n}}</ref> ==Specific ''b''-happy numbers== '
New page size (new_size)
11584
Old page size (old_size)
14215
Size change in edit (edit_delta)
-2631
Lines added in edit (added_lines)
[]
Lines removed in edit (removed_lines)
[ 0 => '', 1 => '== Happy numbers and perfect digital invariants ==', 2 => '{{See also|Perfect digital invariant}}', 3 => 'Formally, let <math>n</math> be a natural number. Given the [[Perfect digital invariant|perfect digital invariant function]] ', 4 => ':<math>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</math>.', 5 => 'for base <math>b > 1</math>, a number <math>n</math> is <math>b</math>-happy if there exists a <math>j</math> such that <math>F_{2, b}^j(n) = 1</math>, where <math>F_{2, b}^j</math> represents the <math>j</math>-th [[Iterated function|iteration]] of <math>F_{2, b}</math>, and <math>b</math>-unhappy otherwise. If a number is a [[#Perfect digital invariant|nontrivial perfect digital invariant]] of <math>F_{2, b}</math>, then it is <math>b</math>-unhappy.', 6 => '', 7 => 'For example, 19 is 10-happy, as', 8 => ': <math>F_{2, 10}(19) = 1^2 + 9^2 = 82</math>', 9 => ': <math>F_{2, 10}^2(19) = F_{2, 10}(82) = 8^2 + 2^2 = 68</math>', 10 => ': <math>F_{2, 10}^3(19) = F_{2, 10}(68) = 6^2 + 8^2 = 100</math>', 11 => ': <math>F_{2, 10}^4(19) = F_{2, 10}(100) = 1^2 + 0^2 + 0^2 = 1</math>', 12 => '', 13 => 'For example, 347 is 6-happy, as', 14 => ': <math>F_{2, 6}(347) = F_{2, 6}(1335_6) = 1^2 + 3^2 + 3^2 + 5^2 = 44</math>', 15 => ': <math>F_{2, 6}^2(347) = F_{2, 6}(44) = F_{2, 6}(112_6) = 1^2 + 1^2 + 2^2 = 6</math>', 16 => ': <math>F_{2, 6}^3(347) = F_{2, 6}(6) = F_{2, 6}(10_6) = 1^2 + 0^2 = 1</math>', 17 => '', 18 => 'There are infinitely many <math>b</math>-happy numbers, as 1 is a <math>b</math>-happy number, and for every <math>n</math>, <math>b^n</math> (<math>10^n</math> in base <math>b</math>) is <math>b</math>-happy, since its sum is 1. The ''happiness'' of a number is preserved by removing or inserting zeroes at will, since they do not contribute to the cross sum.', 19 => '', 20 => '=== Natural density of ''b''-happy numbers ===', 21 => 'By inspection of the first million or so 10-happy numbers, it appears that they have a [[natural 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.<ref>{{Cite journal |title=On the Density of Happy Numbers |journal=Integers |volume=13 |issue=2 |arxiv=1110.3836 |last1=Gilmer |first1=Justin |year=2011 |bibcode=2011arXiv1110.3836G}}</ref>', 22 => '', 23 => '=== Happy bases ===', 24 => '{{unsolved|mathematics|Are [[base 2]] and [[base 4]] the only bases that are happy?}}', 25 => 'A happy base is a number base <math>b</math> where every number is <math>b</math>-happy. The only happy bases less than {{val|5e8}} are [[base 2]] and [[base 4]].<ref>{{Cite OEIS|sequencenumber=A161872|name=Smallest unhappy number in base n}}</ref>' ]
Whether or not the change was made through a Tor exit node (tor_exit_node)
false
Unix timestamp of change (timestamp)
1642372310