A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.
If a number is happy, then all members of its sequence are happy; if a number is unhappy, all members of its sequence are unhappy.
For example, 7 is happy, as the associated sequence is:
The happy numbers below 500 are
Considering more precisely the intervals [244,999], [164,243], [108,163] and [100,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,99] is either happy or goes to the above cycle.
7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239, 263, 293, 313, 331, 367, 379, 383, 397, 409, 487 .All numbers, and therefore all primes, of the form and are happy. To see this, note that these numbers yield values of either 12 + 02 + 02 + ... + 02 + 02 + 32 = 10 → 12 + 02 = 1 or 12 + 02 + 02 + ... + 02 + 02 + 92 = 82 → 82 + 22 = 68 → 62 + 82 = 100 → 12 + 02 + 02 = 1.
The palindromic prime 10150006 + 7426247×1075000 + 1 is also a happy prime with 150007 digits because the many 0's do not contribute to the sum of squared digits, and , which is a happy number. Paul Jobling discovered the prime in 2005..
As of June 2007, the largest known happy prime and the twelfth largest known prime is 4847 × 23321063 + 1. The decimal expansion has 999744 digits: 1844857508...(999724 digits omitted)...2886501377. Richard Hassler and Seventeen or Bust discovered the prime in 2005. Jens K. Andersen identified it as the largest known happy prime in June 2007.
To represent numbers in other bases, we may use a subscript to the right to indicate the base. For instance, represents the number 4, and
By a similar argument to the one above for decimal happy numbers, we can see that unhappy numbers in base lead to cycles of numbers less than . We can use the fact that if , then the sum of the squares of the base- digits of is less than or equal to
In base 2, all numbers are happy. All binary numbers larger than 10002 decay into a value equal to or less than 10002, and all such values are happy: The following four sequences contain all numbers less than :
The only happy bases strictly less than 247 are 2 and 4, yet more could exist outside this range.
, a British author and Senior Lecturer in pure mathematics at Leeds University, by his daughter. She had learned of them at school, but they "may have originated in Russia" .