OFFSET
0,3
COMMENTS
a(n) is the number of ternary strings of length n that contain one or three 1's, zero or two 2's, and have no restriction on the number of 0's.
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (6,-15,20,-15,6,-1).
FORMULA
a(n) = (13/3)*n - (37/6)*n^2 + (43/12)*n^3 - (5/6)*n^4 + (1/12)*n^5.
G.f.: (x*(1 - 4*x + 10*x^2 - 12*x^3 + 15*x^4))/(1 - x)^6.
E.g.f.: exp(x)*(1+x^2/2)*(x+x^3/6).
a(n) = 6*a(n-1) - 15*a(n-2) + 20*a(n-3) - 15*a(n-4) + 6*a(n-5) - a(n-6) for n > 5. - Chai Wah Wu, May 20 2025
EXAMPLE
a(5) = 55 since the strings are the 5 permutations of 10000, the 10 permutations of 11100, the 10 permutations of 11122 and the 30 permutations of 12200.
MATHEMATICA
LinearRecurrence[{6, -15, 20, -15, 6, -1}, {0, 1, 2, 7, 20, 55}, 30] (* Vincenzo Librandi, May 21 2025 *)
PROG
(Magma) [(13/3)*n - (37/6)*n^2 + (43/12)*n^3 - (5/6)*n^4 + (1/12)*n^5: n in [0..40]]; // Vincenzo Librandi, May 21 2025
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Enrique Navarrete, May 15 2025
STATUS
approved
