Happy Primes
A happy number is a number 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 either equals 1 (where it will stay), or it loops endlessly in a cycle that 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 (or sad numbers).
More formally, given a number n=n0, define a sequence n1, n2, ... where ni+1 is the sum of the squares of the digits of ni. Then n is happy if and only if there exists i such that ni=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:
- 12 + 92 = 82
- 82 + 22 = 68
- 62 + 82 = 100
- 12 + 02 + 02 = 1.
First 20: 7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239, 263, 293, 313, 331, 367, 379, 383
Checkout list of first: 10, 50, 100, 500, 1000 happy primes. You can also check all happy primes.
Visualization#
Every frame counter is increased by one. If it is happy prime then dot appears. Color has no meaning. Video has 25fps.
You can also compare it with other types.
External#
- OEIS: A035497
- Wikipedia: Happy Numbers
- Youtube: Visualization up to 1 million
Tags#
Related Articles#
- Dihedral Primes
- Emirps
- Left-truncatable primes
- Long Primes
- Palindromic Primes
- Restricted Left-truncatable primes
- Restricted Right-truncatable primes
- Right-truncatable primes
- Two sided primes
- Weakly Primes
- Additive and Multiplicative Primes
- Additive Primes
- Bell Primes
- Carol Primes
- Centered Decagonal Primes
- Centered Heptagonal Primes
- Centered Square Primes
- Centered Triangular Primes
- Chen Primes
- Class 1+ Primes
- Cousin primes
- Cuban Primes 1
- Cuban Primes 2
- Cullen Primes
- Double Mersenne Primes
- Euclid Primes
- Factorial Primes
- Fermat Primes
- Fibonacci Primes
- Genocchi Primes
- Good Primes
- Harmonic Primes
- Isolated Primes
- Kynea Primes
- Leyland Primes
- Lucas Primes
- Lucky Primes
- Mersenne Primes
- Mills Primes
- Multiplicative Primes
- Pierpont Primes Of the 2nd kind
- Pierpont Primes
- Prime numbers
- Prime Quadruplets
- Prime Quintuplets 1
- Prime Quintuplets 2
- Prime Sextuplets
- Prime Triplets
- Proth Primes
- Pythagorean Primes
- Quartan Primes
- Safe Primes
- Sexy prime quadruplets
- Sexy prime triplets
- Sexy primes
- Solinas Primes
- Sophie Germain Primes
- Super Primes
- Thabit primes of the 2nd kind
- Thabit Primes
- Twin primes
- Ulam Primes
- Wagstaff Primes
- Wedderburn-Etherington Primes
- Wilson Primes
- Woodall Primes