OFFSET
1,1
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 = 4, -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
