Happy Numbers (video Game)
   HOME

TheInfoList



OR:

In
number theory Number theory is a branch of pure mathematics devoted primarily to the study of the integers and arithmetic functions. Number theorists study prime numbers as well as the properties of mathematical objects constructed from integers (for example ...
, a happy 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 because 1^2+3^2=10, and 1^2+0^2=1. On the other hand, 4 is not a happy number because the sequence starting with 4^2=16 and 1^2+6^2=37 eventually reaches 2^2+0^2=4, 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 b-happy number is a
natural number In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positive in ...
in a given
number base In a positional numeral system, the radix (radices) or base is the number of unique digits, including the digit zero, used to represent numbers. For example, for the decimal system (the most common system in use today) the radix is ten, becaus ...
b that eventually reaches 1 when iterated over the perfect digital invariant function for p = 2. 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 Pure mathematics is the study of mathematical concepts independently of any application outside mathematics. These concepts may originate in real-world concerns, and the results obtained may later turn out to be useful for practical applications ...
at
Leeds University The University of Leeds is a public research university in Leeds, West Yorkshire, England. It was established in 1874 as the Yorkshire College of Science. In 1884, it merged with the Leeds School of Medicine (established 1831) and was renamed ...
) by his daughter, who had learned of them at school. However, they "may have originated in Russia" .


Happy numbers and perfect digital invariants

Formally, let n be a natural number. Given the perfect digital invariant function :F_(n) = \sum_^ ^p. for base b > 1, a number n is b-happy if there exists a j such that F_^j(n) = 1, where F_^j represents the j-th
iteration Iteration is the repetition of a process in order to generate a (possibly unbounded) sequence of outcomes. Each repetition of the process is a single iteration, and the outcome of each iteration is then the starting point of the next iteration. ...
of F_, and b-unhappy otherwise. If a number is a nontrivial perfect digital invariant of F_, then it is b-unhappy. For example, 19 is 10-happy, as : F_(19) = 1^2 + 9^2 = 82 : F_^2(19) = F_(82) = 8^2 + 2^2 = 68 : F_^3(19) = F_(68) = 6^2 + 8^2 = 100 : F_^4(19) = F_(100) = 1^2 + 0^2 + 0^2 = 1 For example, 347 is 6-happy, as : F_(347) = F_(1335_6) = 1^2 + 3^2 + 3^2 + 5^2 = 44 : F_^2(347) = F_(44) = F_(112_6) = 1^2 + 1^2 + 2^2 = 6 : F_^3(347) = F_(6) = F_(10_6) = 1^2 + 0^2 = 1 There are infinitely many b-happy numbers, as 1 is a b-happy number, and for every n, b^n (10^n in base b) is b-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 In number theory, natural density, also referred to as asymptotic density or arithmetic density, is one method to measure how "large" a subset of the set of natural numbers is. It relies chiefly on the probability of encountering members of the desi ...
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.


Happy bases

A happy base is a number base b where every number is b-happy. The only happy integer bases less than are base 2 and
base 4 Quaternary is a numeral system with four as its base. It uses the digits 0, 1, 2, and 3 to represent any real number. Conversion from binary is straightforward. Four is the largest number within the subitizing range and one of two numbers ...
.


Specific ''b''-happy numbers


4-happy numbers

For b = 4, the only positive perfect digital invariant for F_ is the trivial perfect digital invariant 1, and there are no other cycles. Because all numbers are preperiodic points for F_, all numbers lead to 1 and are happy. As a result,
base 4 Quaternary is a numeral system with four as its base. It uses the digits 0, 1, 2, and 3 to represent any real number. Conversion from binary is straightforward. Four is the largest number within the subitizing range and one of two numbers ...
is a happy base.


6-happy numbers

For b = 6, the only positive perfect digital invariant for F_ 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 F_, 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

For b = 10, the only positive perfect digital invariant for F_ 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 F_, 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 . 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. . The first pair of consecutive 10-happy numbers is 31 and 32. The first set of three consecutive is 1880, 1881, and 1882. It has been proven that there exist sequences of consecutive happy numbers of any natural number length. The beginning of the first run of at least ''n'' consecutive 10-happy numbers for ''n'' = 1, 2, 3, ... is : 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." The number of 10-happy numbers up to 10''n'' for 1 ≤ ''n'' ≤ 20 is : 3, 20, 143, 1442, 14377, 143071, 1418854, 14255667, 145674808, 1492609148, 15091199357, 149121303586, 1443278000870, 13770853279685, 130660965862333, 1245219117260664, 12024696404768025, 118226055080025491, 1183229962059381238, 12005034444292997294.


Happy primes

A b-happy prime is a number that is both b-happy and
prime A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways ...
. Unlike happy numbers, rearranging the digits of a 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, as base 2 and
base 4 Quaternary is a numeral system with four as its base. It uses the digits 0, 1, 2, and 3 to represent any real number. Conversion from binary is straightforward. Four is the largest number within the subitizing range and one of two numbers ...
are happy bases.


6-happy primes

In
base 6 A senary () numeral system (also known as base-6, heximal, or seximal) has six as its base. It has been adopted independently by a small number of cultures. Like the decimal base 10, the base is a semiprime, though it is unique as the product ...
, the 6-happy primes below 1296 = 64 are :211, 1021, 1335, 2011, 2425, 2555, 3351, 4225, 4441, 5255, 5525


10-happy primes

In
base 10 The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers (''decimal fractions'') of t ...
, 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 . The
palindromic prime In mathematics, a palindromic prime (sometimes called a palprime) is a prime number that is also a palindromic number. Palindromicity depends on the base of the number system and its notational conventions, while primality is independent of such ...
is a 10-happy prime with digits because the many 0s do not contribute to the sum of squared digits, and = 176, which is a 10-happy number. Paul Jobling discovered the prime in 2005. , the largest known 10-happy prime is 242643801 − 1 (a
Mersenne prime In mathematics, a Mersenne prime is a prime number that is one less than a power of two. That is, it is a prime number of the form for some integer . They are named after Marin Mersenne, a French Minim friar, who studied them in the early 1 ...
). Its decimal expansion has digits.


12-happy primes

In
base 12 The duodecimal system, also known as base twelve or dozenal, is a positional notation, positional numeral system using 12 (number), twelve as its radix, base. In duodecimal, the number twelve is denoted "10", meaning 1 twelve and 0 1, units; ...
, 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 p = 2 and a default base 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, and repeating a number. A simple test in
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (prog ...
to check if a number is happy: 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


In popular culture

* In 2007, the concept of happy numbers was used in ''
Professor Layton and the Diabolical Box ''Professor Layton and the Diabolical Box'', known in Australia and Europe as ''Professor Layton and Pandora's Box'', is the second game in the ''Professor Layton'' series by Level-5. It was followed by a third game, '' Professor Layton and the ...
'', in puzzle 149 ("Number Cycle"), using the sequence beginning with 4, which repeats every 8 terms. * In the
Doctor Who ''Doctor Who'' is a British science fiction television series broadcast by the BBC since 1963. The series, created by Sydney Newman, C. E. Webber and Donald Wilson (writer and producer), Donald Wilson, depicts the adventures of an extraterre ...
episode 42, a sequence of happy primes is the password to open a door.


See also

*
Arithmetic dynamics Arithmetic dynamics is a field that amalgamates two areas of mathematics, dynamical systems and number theory. Part of the inspiration comes from complex dynamics, the study of the Iterated function, iteration of self-maps of the complex plane or o ...
*
Fortunate number In number theory, a Fortunate number, named after Reo Fortune, is the smallest integer ''m'' > 1 such that, for a given positive integer ''n'', ''p'n''# + ''m'' is a prime number, where the primorial ''p'n''# is the product of the first '' ...
*
Harshad number In mathematics, a harshad number (or Niven number) in a given radix, number base is an integer that is divisible by the digit sum, sum of its digits when written in that base. Harshad numbers in base are also known as -harshad (or -Niven) numbers ...
*
Lucky number In number theory, a lucky number is a natural number in a set which is generated by a certain " sieve". This sieve is similar to the sieve of Eratosthenes that generates the primes, but it eliminates numbers based on their position in the rema ...
*
Perfect digital invariant In number theory, a perfect digital invariant (PDI) is a number in a given number base (b) that is the sum of its own digits each raised to a given power (p). 0 F_ : \mathbb \rightarrow \mathbb is defined as: :F_(n) = \sum_^ d_i^p. where k = \lfl ...


References


Literature

*


External links

* Schneider, Walter
Mathews: Happy Numbers.
*
calculate if a number is happy


at The Math Forum.

at Numberphile. * {{DEFAULTSORT:Happy Number Arithmetic dynamics Base-dependent integer sequences