OFFSET
1,2
COMMENTS
The sequence is a permutation of the nonprimes.
LINKS
Eric Angelini, Prime combination lock, Personal blog, April 2024.
EXAMPLE
The Levenshtein distance = 1 between 1 and 4, 4 and 6, 6 and 8, 8 and 9, 9 and 39, 39 and 30, 30 and 10, etc.
No smaller composite than 39 was possible for a(6).
MATHEMATICA
a[1]=1; a[n_]:=a[n]=(k=2; While[PrimeQ@k||MemberQ[Array[a, n-1], k]|| EditDistance[ToString@k, ToString@a[n-1]]!=1, k++]; k); Array[a, 77]
PROG
(Python)
from sympy import isprime
from itertools import islice
from Levenshtein import distance as Ld
def agen(): # generator of terms
an, aset, mink = 1, {1}, 4
while True:
yield an
s, k = str(an), mink
while k in aset or Ld(s, str(k)) != 1 or isprime(k): k += 1
an = k
aset.add(k)
while mink in aset or isprime(mink): mink += 1
print(list(islice(agen(), 80))) # Michael S. Branicky, Apr 29 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Eric Angelini and Giorgos Kalogeropoulos, Apr 29 2024
STATUS
approved