Jump to content

Examine individual changes

This page allows you to examine the variables generated by the Edit Filter for an individual change.

Variables generated for this change

VariableValue
Edit count of the user (user_editcount)
null
Name of the user account (user_name)
'2600:1012:B122:80E:49E0:EA3E:8834:30A1'
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 => 'centralauth-merge', 12 => 'abusefilter-view', 13 => 'abusefilter-log', 14 => 'vipsscaler-test' ]
Whether the user is editing from mobile app (user_app)
false
Whether or not a user is editing through the mobile interface (user_mobile)
true
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'
Last ten users to contribute to the page (page_recent_contributors)
[ 0 => 'Andritolion', 1 => '175.158.208.149', 2 => 'Narky Blert', 3 => '2A01:CB1C:1BC:F400:C101:3CDF:D243:7AEA', 4 => 'Orientls', 5 => 'AnomieBOT', 6 => '86.145.58.211', 7 => '37.13.136.178', 8 => 'Mikhail Ryazanov', 9 => 'Marian olarescu ruiz90' ]
Action (action)
'edit'
Edit summary/reason (summary)
'Added content'
Old content model (old_content_model)
'wikitext'
New content model (new_content_model)
'wikitext'
Old page wikitext, before the edit (old_wikitext)
'{{distinguish|text=[[Harshad number]] (derived from Sanskrit ''harśa'' meaning "great joy")}} A '''happy number''' is defined by the following process: Starting with any [[positive number|positive]] [[integer]], replace the number by the [[summation|sum]] of the squares of its [[numerical digit|digits]] in [[decimal|base-ten]], and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that does not include&nbsp;1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are '''unhappy numbers''' (or '''sad numbers''').<ref>{{cite web|url=http://mathworld.wolfram.com/SadNumber.html|title=Sad Number|publisher=Wolfram Research, Inc.|accessdate=2009-09-16}}</ref> == Origin == 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}}. ==Overview== More formally, given a number ''n''&nbsp;=&nbsp;''n''<sub>0</sub>, define a sequence ''n''<sub>1</sub>, ''n''<sub>2</sub>, ..., where ''n''<sub>''i''+1</sub> is the sum of the squares of the digits of ''n<sub>i</sub>''. Then ''n'' is happy if and only if there exists ''i'' such that ''n<sub>i</sub>''&nbsp;=&nbsp;1. If a number is happy, then all members of its sequence are happy; if a number is unhappy, all members of the sequence are unhappy. For example, 19 is happy, as the associated sequence is : 1<sup>2</sup> + 9<sup>2</sup> = 82, : 8<sup>2</sup> + 2<sup>2</sup> = 68, : 6<sup>2</sup> + 8<sup>2</sup> = 100, : 1<sup>2</sup> + 0<sup>2</sup> + 0<sup>2</sup> = 1. The 143 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 happiness of a number is unaffected by rearranging the digits and by inserting or removing any number of zeros anywhere in the number. The distinct combinations of digits that form 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}}. ==Sequence behavior== Numbers that are happy follow a sequence that ends in 1. All unhappy numbers follow sequences that eventually reach the eight-number cycle : 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20 → 4 → ... To see this fact, first note that if ''n'' has ''m'' digits, then the sum of the squares of its digits is at most 9<sup>2</sup>''m'', or 81''m''. For ''m''&nbsp;=&nbsp;4 and above, : <math>n \geq 10^{m-1} > 81m,</math> so any number over 1000 gets smaller under this process and in particular becomes a number with strictly fewer digits. Once we are under 1000, the number for which the sum of squares of digits is largest is 999, and the result is 3&nbsp;×&nbsp;81&nbsp;=&nbsp;243. * In the range 100 to 243, the number 199 produces the largest next value, of 163. * In the range 100 to 163, the number 159 produces the largest next value, of 107. * In the range 100 to 107, the number 107 produces the largest next value, of 50. Considering more precisely the [[Interval (mathematics)|intervals]] [244,&nbsp;999], [164,&nbsp;243], [108,&nbsp;163] and [100,&nbsp;107], we see that every number above 99 gets strictly smaller under this process. Thus, no matter what number we start with, we eventually drop below 100. An exhaustive search then shows that every number in the interval [1,&nbsp;99] either is happy or goes to the above unhappy cycle. The above work produces the interesting result that no positive integer other than 1 is the sum of the squares of its own digits, since any such number would be a fixed point of the described process. There are infinitely many happy numbers and infinitely many unhappy numbers. Consider the following proof: * 1 is a happy number, and for every ''n'', 10<sup>''n''</sup> is happy, since its sum is 1. * For every ''n'', 2&nbsp;×&nbsp;10<sup>''n''</sup> is unhappy, since its sum is 4, and 4 is an unhappy number. Indeed, the ''happiness'' of a number is preserved by removing or inserting zeroes at will, since they do not contribute to the cross sum. See the above proof, especially by appending 0s on the end of the number (multiplying by 10<sup>''n''</sup>). The first pair of consecutive happy numbers is 31 and 32.<ref>{{cite OEIS |1=A035502 |2=Lower of pair of consecutive happy numbers |accessdate=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 |accessdate=8 April 2011}}</ref> It has been proved 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 happy numbers for ''n''&nbsp;= 1, 2, 3, ... is<ref>{{Cite OEIS |1=A055629 |2=Beginning of first run of at least ''n'' consecutive happy numbers}}</ref> : 1, 31, 1880, 7839, 44488, 7899999999999959999999996, 7899999999999959999999996, ... By inspection of the first million or so happy numbers, it appears that they have a [[natural density]] of around 0.15. Perhaps surprisingly, then, the 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> The number of happy numbers up to 10<sup>''n''</sup> for 1&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 prime== A happy prime is a number that is both happy and [[prime number|prime]]. The 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}}. All numbers, and therefore all primes, of the form 10<sup>''n''</sup>&nbsp;+&nbsp;3 or 10<sup>''n''</sup>&nbsp;+&nbsp;9 for ''n'' greater than 0 are happy.{{clarify|reason=are there infinitely many primes of these forms?|date=January 2019}} To see this, note that * All such numbers will have at least two digits. * The first digit will always be 1 due to the 10<sup>''n''</sup>. * The last digit will always be either 3 or 9. * Any other digits will always be 0 (and therefore will not contribute to the sum of squares of the digits). ** The sequence for numbers ending in 3 is: 1<sup>2</sup> + 3<sup>2</sup> = 10 → 1<sup>2</sup> = 1. ** The sequence for numbers ending in 9 is: 1<sup>2</sup> + 9<sup>2</sup> = 82 → 8<sup>2</sup> + 2<sup>2</sup> = 64 + 4 = 68 → 6<sup>2</sup> + 8<sup>2</sup> = 36 + 64 = 100 → 1. (This does not mean that these are the only happy primes, as evidenced by the sequence above.) The [[palindromic prime]] {{nowrap|10<sup>150006</sup> + {{val|7426247e75000}} + 1}} is also a 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 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 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> Unlike happy numbers, rearranging the digits of a happy prime will not necessarily create another happy prime. For instance, while 19 is a happy prime, 91&nbsp;=&nbsp;13&nbsp;×&nbsp;7 is not prime (but is still happy). ==Happy numbers in other bases== The definition of happy numbers depends on the decimal ([[base 10]]) representation of the numbers. The definition can be extended to other [[Radix|bases]]. To represent numbers in other bases, we may use a subscript to the right to indicate the base. For instance, 100<sub>2</sub> represents the number four in [[base 2]], and :<math>123_5 = 1 \cdot 5^2 + 2 \cdot 5 + 3 =38.</math> Then, it is easy to see that there are infinitely many happy numbers in every base. For instance, the numbers :<math>1_b,10_b,100_b,1000_b,... \quad(= b^n \text{ for all positive integers } n)</math> are all happy, for any base ''b''. By a similar argument to the one above for decimal happy numbers, unhappy numbers in base ''b'' lead to cycles of numbers less than 1000<sub>''b''</sub>. If ''n''&nbsp;<&nbsp;1000<sub>''b''</sub>, then the sum of the squares of the base-''b'' digits of ''n'' is less than or equal to :<math>3(b-1)^2</math>, which can be shown to be less than ''b''<sup>3</sup>, for ''b''&nbsp;≥&nbsp;5. This shows that once the sequence reaches a number less than 1000<sub>''b''</sub>, it stays below 1000<sub>b</sub>, and hence must cycle or reach 1. In base 2, all numbers are happy. All [[Binary numeral system|binary]] numbers larger than 1000<sub>2</sub> (8<sub>10</sub>) decay into a value equal to or less than 1000<sub>2</sub>, and all such values are happy: :<math> 111_2 \rightarrow 11_2 \rightarrow 10_2 \rightarrow 1 </math> :<math> 110_2 \rightarrow 10_2 \rightarrow 1 </math> :<math> 101_2 \rightarrow 10_2 \rightarrow 1 </math> :<math> 100_2 \rightarrow 1. </math> Since all sequences lead to 1, we conclude that all numbers are happy in base 2. This makes base 2 a ''happy base''. The only known happy bases are 2 and 4. There are no others less than {{val|5e8}}.<ref>{{Cite OEIS|sequencenumber=A161872|name=Smallest unhappy number in base n}}</ref> Base 3 is also a special case in that the happiness (or sadness) of a number is an indication also of being odd (or even). Specifically, because 3&nbsp;−&nbsp;1&nbsp;=&nbsp;2, the sum of every digit of a base-3 number will indicate divisibility by 2 [[if and only if]] the sum of digits ends in 0 or 2. This is the general application of the test for divisibility by 9 in base 10. In [[balanced ternary]], the digits are 1, −1 and 0. The square of both 1 and −1 are 1, and 1&nbsp;+&nbsp;1 is 2, which is the only balanced ternary cycle. For every pair of digits 1 or −1, their sum is 0 and the sum of their squares is 2 and if there are an even number of {1,&nbsp;−1} sets, the number divisible by 2 and sad and if odd, it is happy. In this case, the result always end in a one-digit cycle of 0, 1 or 2, repeated infinitely. In [[Ternary numeral system|unbalanced ternary]], the digits square to 1 and 4<sub>10</sub> (11<sub>3</sub>,) and in this case there are five loops: 0, 1, {{nowrap|2 → 11<sub>3</sub> → 2}}, 12<sub>3</sub> (5<sub>10</sub>), and 22<sub>3</sub> (8<sub>10</sub>). While all even numbers are sad because they end in the 0, 2 or 22<sub>3</sub> cycle, some odd numbers are also sad because they end in 12<sub>3</sub> or 1, and are thus occasionally sad.{{citation needed|date=June 2013}} In [[duodecimal|base 12]], there is no other happy number between 10 (decimal [[12 (number)|12]]) and 100 (decimal [[144 (number)|144]]), there are three fixed points: 1, 25<sub>12</sub>, ↊5<sub>12</sub>, and four cycles: :5 → 21 → 5 :8 → 54 → 35 → 2↊ → 88 → ↊8 → 118 → 56 → 51 → 22 → 8 :18 → 55 → 42 → 18 :68 → 84 → 68 The numbers 25<sub>12</sub> (29<sub>10</sub>) and ↊5<sub>12</sub> (125<sub>10</sub>) are [[Armstrong number]]s in base 12 {{oeis|id=A161949}}; there are no two-digit Armstrong numbers in base 10. In [[hexadecimal|base 16]], there is only one fixed point: 1, and one cycle: :D → A9 → B5 → 92 → 55 → 32 → D The status in base 16 is similar to base 10. ==Cubing the digits rather than squaring== A variation to the happy numbers problem is to find the sum of the cubes of the digits rather than the sum of the squares of the digits. For example, working in base 10, 1579 is happy, since: : 1<sup>3</sup> + 5<sup>3</sup> + 7<sup>3</sup> + 9<sup>3</sup> = 1 + 125 + 343 + 729 = 1198 : 1<sup>3</sup> + 1<sup>3</sup> + 9<sup>3</sup> + 8<sup>3</sup> = 1 + 1 + 729 + 512 = 1243 : 1<sup>3</sup> + 2<sup>3</sup> + 4<sup>3</sup> + 3<sup>3</sup> = 1 + 8 + 64 + 27 = 100 : 1<sup>3</sup> + 0<sup>3</sup> + 0<sup>3</sup> = 1 In the same way that when summing the squares of the digits (and working in base 10) each number above 243 (=&nbsp;3&nbsp;×&nbsp;9<sup>2</sup>) produces a number that is strictly smaller, when summing the cubes of the digits each number above 2916 (=&nbsp;4&nbsp;×&nbsp;9<sup>3</sup>) produces a number that is strictly smaller. By conducting an exhaustive search of [1,&nbsp;2916] one finds that for summing the cubes of digits base 10 there are happy numbers and eight different types of unhappy number: *those that eventually reach 153, 370, 371, or 407, which perpetually produce themselves; and *those that eventually reach one of the loops: :: 133 → 55 → 250 → 133 :: 217 → 352 → 160 → 217 :: 1459 → 919 → 1459 :: 136 → 244 →136 All multiples of three terminate at 153. This fact can be proved by the exhaustive search up and noting that a number is a multiple of three if and only if the sum of digits is a multiple of three if and only if the sum of its cubed digits are a multiple of three. By similar reasoning, all happy numbers when summing up odd powers (e.g. cubes, fifth powers, seventh powers, etc.) of their digits must have a remainder of 1 when dividing by 3. All numbers that are congruent to 2 [[Modulo operation|modulo]] 3 terminate at either 371 or 407. The only positive whole numbers that are the sum of the cubes of their digits are 1, 153, 370, 371 and 407 {{OEIS|id=A046197}}. == Higher powers == For higher powers, the density of happy numbers declines. Taking the sum of the fourth powers of the digits, one can find that most numbers between 1 and 100 end in the loop: : 13139 → 6725 → 4338 → 4514 → 1138 → 4179 → 9219 → 13139, or alternate between 2178 and 6514, or terminate at 1634, 8208 or 9474 which perpetually produce themselves. ==Programming example== The examples below apply the 'happy' process 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 repeating a number. Everything else is bookkeeping (for example, the Python example precomputes the squares of all 10 digits). A simple test in [[Python (programming language)|Python]] to check if a number is happy:<ref>[http://rosettacode.org/wiki/Happy_Number Happy Number] Rosetta Code</ref> <source lang=python> def square(x): return int(x) * int(x) def happy(number): return sum(map(square, list(str(number)))) def is_happy(number): seen_numbers = set() while number > 1 and (number not in seen_numbers): seen_numbers.add(number) number = happy(number) return number == 1 </source> When the algorithm ends in a cycle of repeating numbers, this cycle always includes the number 4, so it is not even necessary to store previous numbers in the sequence: <source lang=python> def is_happy(n): return (n == 1 or n > 4 and is_happy(happy(n))) </source> ==See also== *[[Fortunate number]] *[[Harshad number]] *[[Lucky number]] ==References== {{reflist}} ==Literature== * {{Cite book | last = Guy | first = Richard | authorlink = Richard K. Guy | year = 2004 | title = Unsolved Problems in Number Theory |edition=3rd | publisher = [[Springer-Verlag]] | isbn= 0-387-20860-7 | ref = harv }} ==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. * [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]]}} {{Use dmy dates|date=June 2011}} {{Classes of natural numbers}} {{Prime number classes}} {{DEFAULTSORT:Happy Number}} [[Category:Base-dependent integer sequences]] [[Category:Recreational mathematics]]'
New page wikitext, after the edit (new_wikitext)
'Fuck her right in the pussy == Origin == 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}}. ==Overview== More formally, given a number ''n''&nbsp;=&nbsp;''n''<sub>0</sub>, define a sequence ''n''<sub>1</sub>, ''n''<sub>2</sub>, ..., where ''n''<sub>''i''+1</sub> is the sum of the squares of the digits of ''n<sub>i</sub>''. Then ''n'' is happy if and only if there exists ''i'' such that ''n<sub>i</sub>''&nbsp;=&nbsp;1. If a number is happy, then all members of its sequence are happy; if a number is unhappy, all members of the sequence are unhappy. For example, 19 is happy, as the associated sequence is : 1<sup>2</sup> + 9<sup>2</sup> = 82, : 8<sup>2</sup> + 2<sup>2</sup> = 68, : 6<sup>2</sup> + 8<sup>2</sup> = 100, : 1<sup>2</sup> + 0<sup>2</sup> + 0<sup>2</sup> = 1. The 143 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 happiness of a number is unaffected by rearranging the digits and by inserting or removing any number of zeros anywhere in the number. The distinct combinations of digits that form 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}}. ==Sequence behavior== Numbers that are happy follow a sequence that ends in 1. All unhappy numbers follow sequences that eventually reach the eight-number cycle : 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20 → 4 → ... To see this fact, first note that if ''n'' has ''m'' digits, then the sum of the squares of its digits is at most 9<sup>2</sup>''m'', or 81''m''. For ''m''&nbsp;=&nbsp;4 and above, : <math>n \geq 10^{m-1} > 81m,</math> so any number over 1000 gets smaller under this process and in particular becomes a number with strictly fewer digits. Once we are under 1000, the number for which the sum of squares of digits is largest is 999, and the result is 3&nbsp;×&nbsp;81&nbsp;=&nbsp;243. * In the range 100 to 243, the number 199 produces the largest next value, of 163. * In the range 100 to 163, the number 159 produces the largest next value, of 107. * In the range 100 to 107, the number 107 produces the largest next value, of 50. Considering more precisely the [[Interval (mathematics)|intervals]] [244,&nbsp;999], [164,&nbsp;243], [108,&nbsp;163] and [100,&nbsp;107], we see that every number above 99 gets strictly smaller under this process. Thus, no matter what number we start with, we eventually drop below 100. An exhaustive search then shows that every number in the interval [1,&nbsp;99] either is happy or goes to the above unhappy cycle. The above work produces the interesting result that no positive integer other than 1 is the sum of the squares of its own digits, since any such number would be a fixed point of the described process. There are infinitely many happy numbers and infinitely many unhappy numbers. Consider the following proof: * 1 is a happy number, and for every ''n'', 10<sup>''n''</sup> is happy, since its sum is 1. * For every ''n'', 2&nbsp;×&nbsp;10<sup>''n''</sup> is unhappy, since its sum is 4, and 4 is an unhappy number. Indeed, the ''happiness'' of a number is preserved by removing or inserting zeroes at will, since they do not contribute to the cross sum. See the above proof, especially by appending 0s on the end of the number (multiplying by 10<sup>''n''</sup>). The first pair of consecutive happy numbers is 31 and 32.<ref>{{cite OEIS |1=A035502 |2=Lower of pair of consecutive happy numbers |accessdate=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 |accessdate=8 April 2011}}</ref> It has been proved 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 happy numbers for ''n''&nbsp;= 1, 2, 3, ... is<ref>{{Cite OEIS |1=A055629 |2=Beginning of first run of at least ''n'' consecutive happy numbers}}</ref> : 1, 31, 1880, 7839, 44488, 7899999999999959999999996, 7899999999999959999999996, ... By inspection of the first million or so happy numbers, it appears that they have a [[natural density]] of around 0.15. Perhaps surprisingly, then, the 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> The number of happy numbers up to 10<sup>''n''</sup> for 1&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 prime== A happy prime is a number that is both happy and [[prime number|prime]]. The 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}}. All numbers, and therefore all primes, of the form 10<sup>''n''</sup>&nbsp;+&nbsp;3 or 10<sup>''n''</sup>&nbsp;+&nbsp;9 for ''n'' greater than 0 are happy.{{clarify|reason=are there infinitely many primes of these forms?|date=January 2019}} To see this, note that * All such numbers will have at least two digits. * The first digit will always be 1 due to the 10<sup>''n''</sup>. * The last digit will always be either 3 or 9. * Any other digits will always be 0 (and therefore will not contribute to the sum of squares of the digits). ** The sequence for numbers ending in 3 is: 1<sup>2</sup> + 3<sup>2</sup> = 10 → 1<sup>2</sup> = 1. ** The sequence for numbers ending in 9 is: 1<sup>2</sup> + 9<sup>2</sup> = 82 → 8<sup>2</sup> + 2<sup>2</sup> = 64 + 4 = 68 → 6<sup>2</sup> + 8<sup>2</sup> = 36 + 64 = 100 → 1. (This does not mean that these are the only happy primes, as evidenced by the sequence above.) The [[palindromic prime]] {{nowrap|10<sup>150006</sup> + {{val|7426247e75000}} + 1}} is also a 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 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 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> Unlike happy numbers, rearranging the digits of a happy prime will not necessarily create another happy prime. For instance, while 19 is a happy prime, 91&nbsp;=&nbsp;13&nbsp;×&nbsp;7 is not prime (but is still happy). ==Happy numbers in other bases== The definition of happy numbers depends on the decimal ([[base 10]]) representation of the numbers. The definition can be extended to other [[Radix|bases]]. To represent numbers in other bases, we may use a subscript to the right to indicate the base. For instance, 100<sub>2</sub> represents the number four in [[base 2]], and :<math>123_5 = 1 \cdot 5^2 + 2 \cdot 5 + 3 =38.</math> Then, it is easy to see that there are infinitely many happy numbers in every base. For instance, the numbers :<math>1_b,10_b,100_b,1000_b,... \quad(= b^n \text{ for all positive integers } n)</math> are all happy, for any base ''b''. By a similar argument to the one above for decimal happy numbers, unhappy numbers in base ''b'' lead to cycles of numbers less than 1000<sub>''b''</sub>. If ''n''&nbsp;<&nbsp;1000<sub>''b''</sub>, then the sum of the squares of the base-''b'' digits of ''n'' is less than or equal to :<math>3(b-1)^2</math>, which can be shown to be less than ''b''<sup>3</sup>, for ''b''&nbsp;≥&nbsp;5. This shows that once the sequence reaches a number less than 1000<sub>''b''</sub>, it stays below 1000<sub>b</sub>, and hence must cycle or reach 1. In base 2, all numbers are happy. All [[Binary numeral system|binary]] numbers larger than 1000<sub>2</sub> (8<sub>10</sub>) decay into a value equal to or less than 1000<sub>2</sub>, and all such values are happy: :<math> 111_2 \rightarrow 11_2 \rightarrow 10_2 \rightarrow 1 </math> :<math> 110_2 \rightarrow 10_2 \rightarrow 1 </math> :<math> 101_2 \rightarrow 10_2 \rightarrow 1 </math> :<math> 100_2 \rightarrow 1. </math> Since all sequences lead to 1, we conclude that all numbers are happy in base 2. This makes base 2 a ''happy base''. The only known happy bases are 2 and 4. There are no others less than {{val|5e8}}.<ref>{{Cite OEIS|sequencenumber=A161872|name=Smallest unhappy number in base n}}</ref> Base 3 is also a special case in that the happiness (or sadness) of a number is an indication also of being odd (or even). Specifically, because 3&nbsp;−&nbsp;1&nbsp;=&nbsp;2, the sum of every digit of a base-3 number will indicate divisibility by 2 [[if and only if]] the sum of digits ends in 0 or 2. This is the general application of the test for divisibility by 9 in base 10. In [[balanced ternary]], the digits are 1, −1 and 0. The square of both 1 and −1 are 1, and 1&nbsp;+&nbsp;1 is 2, which is the only balanced ternary cycle. For every pair of digits 1 or −1, their sum is 0 and the sum of their squares is 2 and if there are an even number of {1,&nbsp;−1} sets, the number divisible by 2 and sad and if odd, it is happy. In this case, the result always end in a one-digit cycle of 0, 1 or 2, repeated infinitely. In [[Ternary numeral system|unbalanced ternary]], the digits square to 1 and 4<sub>10</sub> (11<sub>3</sub>,) and in this case there are five loops: 0, 1, {{nowrap|2 → 11<sub>3</sub> → 2}}, 12<sub>3</sub> (5<sub>10</sub>), and 22<sub>3</sub> (8<sub>10</sub>). While all even numbers are sad because they end in the 0, 2 or 22<sub>3</sub> cycle, some odd numbers are also sad because they end in 12<sub>3</sub> or 1, and are thus occasionally sad.{{citation needed|date=June 2013}} In [[duodecimal|base 12]], there is no other happy number between 10 (decimal [[12 (number)|12]]) and 100 (decimal [[144 (number)|144]]), there are three fixed points: 1, 25<sub>12</sub>, ↊5<sub>12</sub>, and four cycles: :5 → 21 → 5 :8 → 54 → 35 → 2↊ → 88 → ↊8 → 118 → 56 → 51 → 22 → 8 :18 → 55 → 42 → 18 :68 → 84 → 68 The numbers 25<sub>12</sub> (29<sub>10</sub>) and ↊5<sub>12</sub> (125<sub>10</sub>) are [[Armstrong number]]s in base 12 {{oeis|id=A161949}}; there are no two-digit Armstrong numbers in base 10. In [[hexadecimal|base 16]], there is only one fixed point: 1, and one cycle: :D → A9 → B5 → 92 → 55 → 32 → D The status in base 16 is similar to base 10. ==Cubing the digits rather than squaring== A variation to the happy numbers problem is to find the sum of the cubes of the digits rather than the sum of the squares of the digits. For example, working in base 10, 1579 is happy, since: : 1<sup>3</sup> + 5<sup>3</sup> + 7<sup>3</sup> + 9<sup>3</sup> = 1 + 125 + 343 + 729 = 1198 : 1<sup>3</sup> + 1<sup>3</sup> + 9<sup>3</sup> + 8<sup>3</sup> = 1 + 1 + 729 + 512 = 1243 : 1<sup>3</sup> + 2<sup>3</sup> + 4<sup>3</sup> + 3<sup>3</sup> = 1 + 8 + 64 + 27 = 100 : 1<sup>3</sup> + 0<sup>3</sup> + 0<sup>3</sup> = 1 In the same way that when summing the squares of the digits (and working in base 10) each number above 243 (=&nbsp;3&nbsp;×&nbsp;9<sup>2</sup>) produces a number that is strictly smaller, when summing the cubes of the digits each number above 2916 (=&nbsp;4&nbsp;×&nbsp;9<sup>3</sup>) produces a number that is strictly smaller. By conducting an exhaustive search of [1,&nbsp;2916] one finds that for summing the cubes of digits base 10 there are happy numbers and eight different types of unhappy number: *those that eventually reach 153, 370, 371, or 407, which perpetually produce themselves; and *those that eventually reach one of the loops: :: 133 → 55 → 250 → 133 :: 217 → 352 → 160 → 217 :: 1459 → 919 → 1459 :: 136 → 244 →136 All multiples of three terminate at 153. This fact can be proved by the exhaustive search up and noting that a number is a multiple of three if and only if the sum of digits is a multiple of three if and only if the sum of its cubed digits are a multiple of three. By similar reasoning, all happy numbers when summing up odd powers (e.g. cubes, fifth powers, seventh powers, etc.) of their digits must have a remainder of 1 when dividing by 3. All numbers that are congruent to 2 [[Modulo operation|modulo]] 3 terminate at either 371 or 407. The only positive whole numbers that are the sum of the cubes of their digits are 1, 153, 370, 371 and 407 {{OEIS|id=A046197}}. == Higher powers == For higher powers, the density of happy numbers declines. Taking the sum of the fourth powers of the digits, one can find that most numbers between 1 and 100 end in the loop: : 13139 → 6725 → 4338 → 4514 → 1138 → 4179 → 9219 → 13139, or alternate between 2178 and 6514, or terminate at 1634, 8208 or 9474 which perpetually produce themselves. ==Programming example== The examples below apply the 'happy' process 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 repeating a number. Everything else is bookkeeping (for example, the Python example precomputes the squares of all 10 digits). A simple test in [[Python (programming language)|Python]] to check if a number is happy:<ref>[http://rosettacode.org/wiki/Happy_Number Happy Number] Rosetta Code</ref> <source lang=python> def square(x): return int(x) * int(x) def happy(number): return sum(map(square, list(str(number)))) def is_happy(number): seen_numbers = set() while number > 1 and (number not in seen_numbers): seen_numbers.add(number) number = happy(number) return number == 1 </source> When the algorithm ends in a cycle of repeating numbers, this cycle always includes the number 4, so it is not even necessary to store previous numbers in the sequence: <source lang=python> def is_happy(n): return (n == 1 or n > 4 and is_happy(happy(n))) </source> ==See also== *[[Fortunate number]] *[[Harshad number]] *[[Lucky number]] ==References== {{reflist}} ==Literature== * {{Cite book | last = Guy | first = Richard | authorlink = Richard K. Guy | year = 2004 | title = Unsolved Problems in Number Theory |edition=3rd | publisher = [[Springer-Verlag]] | isbn= 0-387-20860-7 | ref = harv }} ==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. * [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]]}} {{Use dmy dates|date=June 2011}} {{Classes of natural numbers}} {{Prime number classes}} {{DEFAULTSORT:Happy Number}} [[Category:Base-dependent integer sequences]] [[Category:Recreational mathematics]]'
Unified diff of changes made by edit (edit_diff)
'@@ -1,4 +1,3 @@ -{{distinguish|text=[[Harshad number]] (derived from Sanskrit ''harśa'' meaning "great joy")}} -A '''happy number''' is defined by the following process: Starting with any [[positive number|positive]] [[integer]], replace the number by the [[summation|sum]] of the squares of its [[numerical digit|digits]] in [[decimal|base-ten]], and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that does not include&nbsp;1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are '''unhappy numbers''' (or '''sad numbers''').<ref>{{cite web|url=http://mathworld.wolfram.com/SadNumber.html|title=Sad Number|publisher=Wolfram Research, Inc.|accessdate=2009-09-16}}</ref> +Fuck her right in the pussy == Origin == '
New page size (new_size)
17223
Old page size (old_size)
17960
Size change in edit (edit_delta)
-737
Lines added in edit (added_lines)
[ 0 => 'Fuck her right in the pussy' ]
Lines removed in edit (removed_lines)
[ 0 => '{{distinguish|text=[[Harshad number]] (derived from Sanskrit ''harśa'' meaning "great joy")}}', 1 => 'A '''happy number''' is defined by the following process: Starting with any [[positive number|positive]] [[integer]], replace the number by the [[summation|sum]] of the squares of its [[numerical digit|digits]] in [[decimal|base-ten]], and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that does not include&nbsp;1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are '''unhappy numbers''' (or '''sad numbers''').<ref>{{cite web|url=http://mathworld.wolfram.com/SadNumber.html|title=Sad Number|publisher=Wolfram Research, Inc.|accessdate=2009-09-16}}</ref>' ]
Whether or not the change was made through a Tor exit node (tor_exit_node)
false
Unix timestamp of change (timestamp)
1554420428