login
A389727
a(n) is the greatest prime > a(n-1) obtained by inserting a single digit anywhere in its string of digits (including at the beginning or end), starting with a(1) = 7.
8
7, 97, 997, 9973, 99793, 997973, 9987973, 99987973, 999879773, 9998797073, 99987970783, 999879970783, 9999879970783, 99998799707083, 999987999707083, 9999879997097083, 99998799970970839, 999987999709707839, 9999879997097097839, 99998799997097097839, 999987999970970976839
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
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)))
KEYWORD
nonn,base
AUTHOR
Michael S. Branicky, Oct 16 2025
STATUS
approved