OFFSET
0,4
COMMENTS
a(n) is the number of ternary strings of length n that contain zero or two 1's, two or three 2's, and have no restriction on the number of 0's.
LINKS
Paolo Xausa, Table of n, a(n) for n = 0..10000
Index entries for linear recurrences with constant coefficients, signature (6,-15,20,-15,6,-1).
FORMULA
a(n) = (1/3)*n - (17/12)*n^2 + (19/12)*n^3 - (7/12)*n^4 + (1/12)*n^5.
G.f.: (x^2*(4*x^3 + 7*x^2 - 2*x + 1))/(1 - x)^6.
E.g.f.: exp(x)*(1 + x^2/2)*(x^2/2 + x^3/6).
EXAMPLE
a(5) = 60 since the strings are the 10 permutations of 22000, the 10 permutations of 22200, the 30 permutations of 11220 and the 10 permutations of 11222.
MATHEMATICA
LinearRecurrence[{6, -15, 20, -15, 6, -1}, {0, 0, 1, 4, 16, 60}, 50] (* or *)
A380445[n_] := n*(n - 1)*(n*(n*(n - 6) + 13) - 4)/12;
Array[A380445, 50, 0] (* Paolo Xausa, Jun 25 2025 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Enrique Navarrete, Jun 21 2025
STATUS
approved
