OFFSET
0,1
COMMENTS
The terms cannot start with a leading zero so any number including a zero must have at least one digit greater than zero as its first digit. See the examples below.
LINKS
Scott R. Shannon, Table of n, a(n) for n = 0..9999
Scott R. Shannon, Image of the first 100000 terms. The green line is y = n.
EXAMPLE
a(9) = 19 as there is no smaller number that includes the digit 9 but does not equal 9.
a(10) = 100 as there is no smaller number that includes the digits 1 and 0 but does not equal 10. Note that '01' = 1 is not allowed.
a(20) = 102 as there is no smaller number that includes the digits 2 and 0 but does not equal 20. Note that '02' = 2 is not allowed.
a(22) = 122 as there is no smaller number that includes two 2 digits but does not equal 22.
a(200) = 1002 as there is no smaller number that includes two 0 digits and the digit 2 but does not equal 200.
PROG
(PARI) vd(n) = my(d=if (n, digits(n), [0])); vector(10, k, #select(x->(x==k-1), d));
isok(k, n, d) = if (k!=n, my(dd=vd(k)); for (i=1, #d, if (dd[i] < d[i], return(0))); return(1));
a(n) = my(k=0, d=vd(n)); while(!isok(k, n, d), k++); k; \\ Michel Marcus, May 17 2022
(Python)
def ok(k, n):
if k == n: return False
sk, sn = str(k), str(n)
return all(sk.count(d) >= sn.count(d) for d in set(sn))
def a(n):
k = 0
while not ok(k, n): k += 1
return k
print([a(n) for n in range(71)]) # Michael S. Branicky, May 23 2022
CROSSREFS
KEYWORD
AUTHOR
Scott R. Shannon and Zach J. Shannon, May 16 2022
STATUS
approved