OFFSET
1,1
COMMENTS
The sequence is a permutation of the prime numbers.
LINKS
Eric Angelini, Prime combination lock, Personal blog, April 2024.
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)
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
AUTHOR
Eric Angelini and Giorgos Kalogeropoulos, Apr 29 2024
STATUS
approved