login
A372407
a(n) = smallest prime not occurring earlier having in decimal representation to its predecessor Levenshtein distance = 1.
4
2, 3, 5, 7, 17, 11, 13, 19, 29, 23, 43, 41, 31, 37, 47, 67, 61, 71, 73, 53, 59, 79, 89, 83, 283, 223, 227, 127, 107, 101, 103, 109, 139, 131, 137, 157, 151, 181, 191, 193, 113, 163, 167, 197, 97, 397, 307, 317, 311, 211, 241, 251, 257, 277, 271, 281, 881, 811, 821, 421, 401, 409, 419, 439
OFFSET
1,1
COMMENTS
The sequence is a permutation of the prime numbers.
The sequence is finite, the final term being a(10699272) = 8074013, after which all terms with Levenshtein distance 1 from 8074013 result in composites or primes that have already appeared in the sequence. This contradicts the claim that the sequence is a permutation of the prime numbers. The largest term is a(8534782) = 110010155089, while the list of missing primes is 1989961, 2982997, 2989367, 2996453, ... . - Scott R. Shannon and Michael S. Branicky, Nov 03 2025
A similar sequence which allows for the removal of subsequent leading zeros after the first digit is removed, hence creating a number which has a Levenshtein distance of more than 1 from the previous term, shares the first 844 terms with the present sequence, but then has a(845) = 929. That sequence is also finite with a final term a(9656503) = 8074013. - Scott R. Shannon, Nov 03 2025
LINKS
Scott R. Shannon and Michael S. Branicky, Table of n, a(n) for n = 1..10000
Eric Angelini, Prime combination lock, Personal blog, April 2024.
Michael S. Branicky, Python program for OEIS A372407
EXAMPLE
The Levenshtein distance = 1 between 2 and 3, 3 and 5, 5 and 7, 7 and 17, 17 and 11, 11 and 13, etc.
No smaller prime than 17 was possible for a(5).
MATHEMATICA
a[1]=2; a[n_]:=a[n]=(k=2; While[MemberQ[Array[a, n-1], k]|| EditDistance[ToString@k, ToString@a[n-1]]!=1, k=NextPrime@k]; k); Array[a, 68]
PROG
(Python) # see Links for a faster version suitable for generating the full sequence
from sympy import isprime
from itertools import islice
from Levenshtein import distance as Ld
def agen(): # generator of terms
an, aset, mink = 2, {2}, 3
while True:
yield an
s, k = str(an), mink
while k in aset or Ld(s, str(k)) != 1 or not isprime(k): k += 1
an = k
aset.add(k)
while mink in aset or not isprime(mink): mink += 1
print(list(islice(agen(), 70))) # Michael S. Branicky, Apr 29 2024
CROSSREFS
KEYWORD
base,nonn,fini
AUTHOR
STATUS
approved