OFFSET
1,2
COMMENTS
The sequence is finite. 1023456789 should be the last number in the sequence, although many smaller numbers should fail to appear. How many terms are in the complete sequence?
The last term is a(1023445778) = 1023456789, the least missing number is 1000000010. - Rémy Sigrist, Jun 03 2022
At that point, the least missing numbers containing the digits 2..9 are 1020001000, 1023001300, 1023401000, 1023450200, 1023456024, 1023456710, 1023456781, 1023456789, resp. - Michael S. Branicky, Aug 26 2022
LINKS
Sergio Pimentel, Table of n, a(n) for n = 1..10000
Rémy Sigrist, C++ program
EXAMPLE
a(11)=12 since a(10)=10 and 12 is the smallest number not occurring earlier in the sequence that contains a digit (2) that is not in 10.
PROG
(PARI) isok(k, prev) = {my(d=digits(k)); for (i=1, #d, if (!vecsearch(prev, d[i]), return(1)); ); return(0); }
find(va, n) = {my(k=1, prev=Set(digits(va[n-1]))); while (vecsearch(Set(va), k) || !isok(k, prev), k++); k; }
lista(nn) = {my(va = vector(nn)); va[1] = 1; for (n=2, nn, va[n] = find(va, n); ); va; } \\ Michel Marcus, May 11 2022
(C++) See Links section.
(Python)
from itertools import count, islice
def agen(): # generator of terms
an, aset, mu, mink = 0, set(), [10, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1
while set(str(an)) != set("0123456789"):
notin = set("0123456789") - set(str(an))
an = min(mu[i] for i in range(10) if str(i) in notin)
yield an; aset.add(an)
for i in range(10): # update min unused containing digit i
while mu[i] in aset or str(i) not in str(mu[i]): mu[i] += 1
for k in range(mink, min(mu)): aset.discard(k)
mink = min(mu)
print(list(islice(agen(), 67))) # Michael S. Branicky, Aug 26 2022
CROSSREFS
KEYWORD
nonn,base,fini
AUTHOR
Sergio Pimentel, May 09 2022
STATUS
approved