login
A387852
The final prime number in the base n sequence when starting from 2 and creating the smallest unused prime number, when read in base n, by either removing or adding a single digit, from 0 to n-1, anywhere in the base n value of the previous number. If the base n sequence does not terminate, a(n) = -1.
6
103, 3, 67137547, 947, 2176839901, 80707343, 19604693, 6461081889231955423079731, 1200000000413309
OFFSET
2,1
COMMENTS
See b-file for other known terms (too large for the data section).
The a(11) final value is noteworthy in that the base 11 sequence only contains 659 terms before reaching this value, the length of which contains 111 base 11 digits. From this value 1342 possible candidate numbers can be created for the next term, but remarkably only one of these is prime - the previously used term.
See A389926 for the length of each sequence in base n.
It is conjectured that the sequence of primes in base n terminates for all n.
LINKS
EXAMPLE
a(2) = 103. See A389925.
a(10) = 1200000000413309. See A389825.
a(3) = 3 as in base 3 the entire sequence is: 2 = 2_3, 5 = 12_3, 11 = 102_3, 3 = 10_3, and 3 = 10_3 is the final term as no primes can be created from removing a digit from 10_3, while the only prime that can be created from adding a 0, 1 or 2 digit is 11 = 102_3, but that has already been used.
PROG
(Python)
from gmpy2 import digits, is_prime, mpz
def a(n):
base, prevan = n, None
an, aset, digset = 2, {2}, "".join(digits(i, base) for i in range(base))
while an != -1:
aset.add(an)
prevan = an
s = digits(an, base)
D = set(p for i in range(len(s)) if len(t:=s[:i]+s[i+1:]) and is_prime(p:=mpz(t, base)))
if D and (Dcands:=D-aset):
an = min(D - aset)
continue
A = set(p for i in range(len(s)+1) for d in digset if is_prime(p:=mpz(s[:i]+d+s[i:], base)))
an = min(Acands) if A and (Acands:=A-aset) else -1
return int(prevan)
print([a(n) for n in range(2, 10)]) # Michael S. Branicky, Oct 21 2025
CROSSREFS
Cf. A389825 (base 10), A389925 (base 2), A389926 (total length), A389824, A000040, A080603, A080608, A068166.
Sequence in context: A225993 A237432 A370404 * A279242 A094095 A187882
KEYWORD
nonn,base
AUTHOR
Scott R. Shannon, Oct 19 2025
STATUS
approved