OFFSET
0,3
COMMENTS
Number of ternary strings of length n with none or one 1's, none or two 0's, and an even number of 2's.
LINKS
Index entries for linear recurrences with constant coefficients, signature (0,4,0,-6,0,4,-1).
FORMULA
a(n) = binomial(n,2) + 1, n even.
a(n) = 3*binomial(n,3) + n, n odd.
G.f.: (1 + x - 2*x^2 + 2*x^3 + 5*x^4 + 17*x^5 - 4*x^6 + 4*x^7)/(1 - x^2)^4. - Vaclav Kotesovec, Oct 16 2025
EXAMPLE
a(4) = 7 since the strings are 2222 and the 6 permutations of 0022.
a(5) = 35 since the strings are the 30 permutations of 00122 and the 5 permutations of 12222.
MATHEMATICA
a[n_] := If[EvenQ[n], Binomial[n, 2] + 1, 3*Binomial[n, 3] + n]; Array[a, 54, 0] (* Amiram Eldar, Oct 21 2025 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Enrique Navarrete, Oct 15 2025
STATUS
approved
