OFFSET
0,4
COMMENTS
a(n) is the number of ternary strings of length n that contain at least two 1s or at least three 2s (or both).
LINKS
Index entries for linear recurrences with constant coefficients, signature (7,-18,22,-13,3).
FORMULA
a(n) = 7*a(n-1) - 18*a(n-2) + 22*a(n-3) - 13*a(n-4) + 3*a(n-5), n>4.
From Stefano Spezia, Apr 24 2025: (Start)
G.f.: x^2*(1 + x + 4*x^2)/((1 - x)^4*(1 - 3*x)).
E.g.f.: exp(3*x) - exp(x)*(2 + 4*x + 3*x^2 + x^3)/2. (End)
a(n) = 3^n - A127873(n-1).
EXAMPLE
a(3) = 8 since the strings are 110 (3 of this type), 112 (3 of this type), 111, and 222.
MATHEMATICA
a[n_] := 3^n - 3*Binomial[n, 3] - 3*Binomial[n, 2] - 2*n - 1; Array[a, 31, 0] (* Amiram Eldar, Apr 24 2025 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Enrique Navarrete, Apr 23 2025
STATUS
approved
