OFFSET
1,2
LINKS
Colin Barker, Table of n, a(n) for n = 1..1000
P. R. J. Asveld, Generating all permutations by context-free grammars in Chomsky normal form, Theoretical Computer Science 354 (2006) 118-130.
Index entries for linear recurrences with constant coefficients, signature (7,-17,17,-6).
FORMULA
a(n) = 3^n - 2^(n+1) + n + 1.
G.f.: x*(4*x^2-3*x+1) / ((x-1)^2*(2*x-1)*(3*x-1)). - Colin Barker, Jan 15 2015
E.g.f.: exp(x)*(1 - 2*exp(x) + exp(2*x) + x). - Stefano Spezia, Apr 25 2023
EXAMPLE
S -> AD | DA | BE | EB | CF | FC, D -> BC | CB, E -> AC | CA, F -> AB | BA, A -> a, B -> b, C -> c; so a(3)=15.
MATHEMATICA
f[n_] := 3^n - 2^(n + 1) + n + 1; Table[ f[n], {n, 1, 26}] (* Robert G. Wilson v, Jan 30 2004 *)
PROG
(PARI) Vec(x*(4*x^2-3*x+1)/((x-1)^2*(2*x-1)*(3*x-1)) + O(x^100)) \\ Colin Barker, Jan 15 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Peter R. J. Asveld, Jan 27 2004
EXTENSIONS
More terms from Robert G. Wilson v, Jan 30 2004
STATUS
approved