OFFSET
1,1
COMMENTS
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
Archimedes' Lab, What's Special About This Number?, section about 43.
EXAMPLE
Starting with 8, one can get the primes 83 and 89 which is larger, but 83 allows one further extension to 839 while 89 does not (no prime in the range 890..899). No further extension is possible, since there are no primes in the range 8390,...,8399. Therefore a(8)=839 and A232128(8)=2.
a(20)=a(42)=0 since no prime can be obtained by appending one digit to 20 or 42.
PROG
(PARI) {A232129(n)=local(t(p)=my(m, r=[0, p]); forstep(d=1, 9, 2, isprime(p*10+d)&&(m=t(10*p+d)+[1, 0])[1]>=r[1]&&r=m); r); n<(n=t(n))[2]&&return(n[2])}
(Python)
from sympy import isprime, nextprime
def a(n):
while True:
extends, reach, maxp = -1, {n}, 0
while len(reach) > 0:
candidates = (int(str(e)+d) for d in "1379" for e in reach)
reach1 = set(filter(isprime, candidates))
extends, reach, maxp = extends+1, reach1, max({maxp}|reach1)
return maxp
print([a(n) for n in range(1, 36)]) # Michael S. Branicky, Sep 07 2021
CROSSREFS
KEYWORD
nonn,base,changed
AUTHOR
M. F. Hasler, Nov 19 2013
STATUS
approved