A353888 a(n) is the least positive integer not occurring earlier in the sequence that contains at least one digit not in a(n-1); a(1)=1.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 11, 21, 23, 24, 25, 26, 27, 28, 29, 30, 22, 31, 32, 34, 35, 36, 37, 38, 39, 40, 33, 41, 42, 43, 45, 46, 47, 48, 49, 50, 44, 51, 52, 53, 54, 56, 57, 58, 59, 60, 55, 61, 62, 63, 64, 65, 67, 68
Offset: 1
Examples
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.
Links
- Sergio Pimentel, Table of n, a(n) for n = 1..10000
- Rémy Sigrist, C++ program
Programs
-
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
Comments