OFFSET
0,2
LINKS
Michael S. Branicky, Table of n, a(n) for n = 0..10000
FORMULA
For n > 28, and 2 <= j <= 10, a(j*10^k) = j*10^k + (j-1).
EXAMPLE
[10] is the smallest available integer having a "0". [1] is the smallest available integer having a "1" or a "0". [11] is the smallest integer having a 1, etc.
When restricted to {0..9999} this sequence is a permutation with the following cycle representation:
(1, 10, 23, 27, 19, 6, 20, 16, 5, 2)
(3, 11, 22, 7, 21, 17, 25, 8, 13, 4, 12, 24, 28, 9)
(18, 26)
(30, 32, 31)
(40, 43, 42, 41)
(50, 54, 53, 52, 51)
(60, 65, 64, 63, 62, 61)
(70, 76, 75, 74, 73, 72, 71)
(80, 87, 86, 85, 84, 83, 82, 81)
(100, 109, 108, 107, 106, 105, 104, 103, 102, 101)
(200, 201)
(300, 302, 301)
(400, 403, 402, 401)
(500, 504, 503, 502, 501)
(600, 605, 604, 603, 602, 601)
(700, 706, 705, 704, 703, 702, 701)
(800, 807, 806, 805, 804, 803, 802, 801)
(1000, 1009, 1008, 1007, 1006, 1005, 1004, 1003, 1002, 1001)
(2000, 2001)
(3000, 3002, 3001)
(4000, 4003, 4002, 4001)
(5000, 5004, 5003, 5002, 5001)
(6000, 6005, 6004, 6003, 6002, 6001)
(7000, 7006, 7005, 7004, 7003, 7002, 7001)
(8000, 8007, 8006, 8005, 8004, 8003, 8002, 8001)
- Jason Kimberley, Dec 22 2011
MATHEMATICA
f[l_] := Block[{c = 0}, While[ MemberQ[l, c] || Intersection @@ IntegerDigits /@ {Last[l], c} == {}, c++ ]; Return[Append[l, c]] ]; Nest[f, {0}, 71] (* Ray Chandler, May 23 2005 *)
PROG
(Python)
from itertools import count, islice
def agen(): # generator of terms
an, aset, mink = 0, {0}, 1
while True:
yield an
digset = set(str(an))
an = next(k for k in count(mink) if k not in aset and set(str(k))&digset)
aset.add(an)
while mink in aset: mink += 1
print(list(islice(agen(), 72))) # Michael S. Branicky, Oct 03 2024
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Eric Angelini, May 21 2005
EXTENSIONS
Extended by Ray Chandler, May 23 2005
STATUS
approved