OFFSET
1,1
COMMENTS
Starting with 9 gives 9, 97, ..., matching this sequence from a(2) onward.
Starting with 0 gives 7, so it would be 0 followed by this sequence.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..1000
PROG
(Python)
from gmpy2 import is_prime
from itertools import islice
def f(n): # A389720
s = str(n)
return max((p for i in range(len(s)+1) for d in "0123456789" if is_prime(p:=int(s[:i]+d+s[i:]))), default=-1)
def agen(): # generator of terms
an, prevan = 7, -1
while an > prevan:
yield an
an, prevan = f(an), an
print(list(islice(agen(), 21)))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michael S. Branicky, Oct 16 2025
STATUS
approved
