OFFSET
0,4
COMMENTS
Inspired by Look-and-Say sequences.
LINKS
Rainer Rosenthal, Table of n, a(n) for n = 0..106473
EXAMPLE
a(4) = 2 by definition and a(5) = 2 because "2" appears twice in the string built from the first 5 entries, i.e. "01122".
Nice question: how to continue 0112223141516171819110111? Answer: 4, since 11 was put last and there are 4 occurrences of 11 so far.
MAPLE
rev:=proc(f)local i, fr; fr:=[]; for i to nops(f) do fr:=[op(fr), f[-i]]od; return fr; end:mc := z->`if`(z=0, [0], rev(convert(z, base, 10))):
matches := proc(f, z)local i, t, cnt; t:=mc(z); cnt:=0; for i to nops(f)+1-nops(t)do if f[i..i+nops(t)-1]=t then cnt := cnt+1; fi; od; return cnt; end:
addZ := proc(f, z)local t; t:=mc(z); return[op(f), op(t)]; end:
s:=[]:a:=[]:for i from 0 to 54 do s:=addZ(s, i); m:=matches(s, i); s:=addZ(s, m); a:=[op(a), i, m]; od:seq(a[i+1], i=0..109);
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rainer Rosenthal, Jun 05 2016
STATUS
approved