OFFSET
0,2
COMMENTS
The language of all such words is an example of a context-free language that can only be generated by ambiguous grammars.
REFERENCES
M. Sipser, An Introduction to the Theory of Computation, PWS Publishing Co., 1997, page 98.
FORMULA
G.f.: (1 + 2*x + 3*x^2)/(1 - x^2 - x^3 + x^5).
a(n) = a(n-2) + a(n-3) - a(n-5) for n >= 5.
EXAMPLE
a(6) = 7 because we have: 000000, 000012, 000111, 001122, 012222, 111222, 222222.
MAPLE
a:= n-> 2 +2*iquo(n, 2) -`if`(irem(n, 3)=0, 1, 0):
seq(a(n), n=0..100); # Alois P. Heinz, Jan 27 2014
MATHEMATICA
nn=60; a=1/(1-x); b=1/(1-x^2); c=1/(1-x^3);
CoefficientList[Series[2 a b-c, {x, 0, nn}], x]
CROSSREFS
KEYWORD
nonn
AUTHOR
Geoffrey Critzer, Jan 27 2014
STATUS
approved