OFFSET
0,3
COMMENTS
Rearrangement of nonnegative integers.
a(n) = n for n = 0, 1, 67, 99, ...
LINKS
Paolo P. Lava, Table of n, a(n) for n = 0..10000
EXAMPLE
a(0) = 0; a(1) = 1 because is the least number not yet present in the sequence; a(2) should start with [(10 - 1) mod 10] = [9 mod 10] = 9 and being 9 not yet present in the sequence then a(2) = 9; a(3) should start with [(10 - 9) mod 10] = [1 mod 10] = 1 but 1 is already present and the least integer we can choose is 10, so a(3) = 10; now LSD(a(3)) is 0 and we can simply choose the least number not yet present that is 2: therefore a(4) = 2; and so on.
MAPLE
P:=proc(q) local a, b, c, n, t, v; v:=[0]; t:=0; for n from 2 to q do a:=10-(v[n-1] mod 10) mod 10;
if a=0 then while numboccur(v, t)>0 do t:=t+1; od; v:=[op(v), t]; else
if numboccur(v, a)=0 then v:=[op(v), a]; else c:=-1; b:=a;
while numboccur(v, b)>0 do c:=c+1; if c=0 then b:=10*a; else b:=a*10^length(c)+c; fi; od;
v:=[op(v), b]; fi; fi; od; op(v); end: P(10^2);
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
Paolo P. Lava, Dec 24 2024
STATUS
approved
