MathUpdate tweeted this afternoon that
Any number made by removing the first n digits of 646216567629137 is still prime.
Suffixes of 357686312646216567629137 (all primes)
which implies you can start with an even larger number, cutting off the first digit each time and producing a sequence of primes.
The following Python code verifies that this is indeed the case.
from sympy.ntheory import isprime x = "357686312646216567629137" while x: print isprime(int(x)) x = x[1:]
Update: lucio wrote a program to show that the prime given here is the longest one with the suffix property.
def extend_prime(n, result): for i in range(10): nn = int(str(i) + str(n)) if nn == n: continue if isprime(nn): result.append(nn) extend_prime(nn, result) return result print "Max Prefix Prime:", max(extend_prime("", ))
One minor suggestion: by using
range(1, 10) rather than
range(10) above, i.e. eliminating 0, the line
if nn == n: continue could be eliminated.
Instead of calling
max, you could call
len to find that there are 4260 suffix primes.
Here’s a list of all suffix primes created by the code above and sorting the output.
Other novelty primes:
For daily tweets on algebra and other math, follow @AlgebraFact on Twitter.