VOOZH about

URL: https://oeis.org/A389927

⇱ A389927 - OEIS


login
A389927
The total length of the sequence when starting from n and creating the smallest unused prime number by either removing or adding a single digit anywhere in the value of the previous number. If the sequence does not terminate, a(n) = -1.
1
17608, 205696, 205694, 17612, 205696, 17614, 200955, 205696, 17621, 17608, 17607, 205697, 17604, 17622, 205697, 17606, 175096, 17609, 17620, 205697, 205697, 205697, 205710, 205697, 205697, 205697, 205697, 205697, 205697, 205695, 162055, 205697, 205695, 205695
OFFSET
1,1
COMMENTS
See A389824 and A389825 for the sequence terms when starting at 1 and 2 respectively.
It is conjectured that the sequence of primes terminates for all starting values.
LINKS
FORMULA
From Michael S. Branicky, Oct 22 2025: (Start)
a(n) = 1 + a(A389929(n)) for n composite, in particular
a(n) = 1 when A389929(n) = 0. (End)
EXAMPLE
a(1) = 17608. See A389824.
a(2) = 205696. See A389825.
PROG
(Python)
from gmpy2 import is_prime
from functools import cache
def f(n, avoid):
s = str(n)
D = set(p for i in range(len(s)) if len(t:=s[:i]+s[i+1:]) and is_prime(p:=int(t)))
if D and (Dcands:=D-avoid):
return min(Dcands)
A = set(p for i in range(len(s)+1) for d in "0123456789" if is_prime(p:=int(s[:i]+d+s[i:])))
return min(Acands) if A and (Acands:=A-avoid) else 0
@cache
def a(n):
if n > 1 and not is_prime(n):
fn = f(n, set())
return 1 if (fn:=f(n, set())) == 0 else 1 + a(fn)
an, aset = n, {n}
while an != 0:
aset.add(an)
an = f(an, aset)
return len(aset)
# Michael S. Branicky, Oct 22 2025
KEYWORD
nonn,base
AUTHOR
Scott R. Shannon, Oct 19 2025
STATUS
approved