|
|
A231426
|
|
Least prime such that at most n digits may be appended to the right, preserving primality at each step.
|
|
1
|
|
|
53, 11, 97, 17, 71, 43, 13, 2, 19, 103, 409, 1457011, 2744903797, 5232781111
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,1
|
|
LINKS
|
|
|
FORMULA
|
a(n) is the least prime p=prime(k) such that A232128(p) (= A232127(k)) = n.
|
|
EXAMPLE
|
a(7) = 2 is the least prime which starts several sequences of 1+7 primes, e.g., (2, 23, 239, 2393, ..., 23399339) and others leading at most to 29399999 = A232129(2), where a digit is appended 7 times to yield a prime after each step, while it is not possible in any of the "branches" to append one more digit to the last term, preserving primality.
|
|
PROG
|
(Python)
from sympy import isprime, nextprime
def a(n):
p = 2
while True:
extends, reach = -1, {p}
while len(reach) > 0:
candidates = (int(str(e)+d) for d in "1379" for e in reach)
reach1 = set(filter(isprime, candidates))
extends, reach = extends + 1, reach1
if extends == n: return p
p = nextprime(p)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,more
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|