OFFSET
0,4
COMMENTS
a(n) is the number of ternary strings of length n that contain at least three 1's or at least three 2's (or both).
LINKS
Paolo Xausa, Table of n, a(n) for n = 0..2000
Index entries for linear recurrences with constant coefficients, signature (8,-25,40,-35,16,-3).
FORMULA
E.g.f.: exp(x)*(exp(2*x)-(1 + x + x^2/2)^2).
a(n) = 3^n - A385689(n).
G.f.: 2*x^3*(1 + x + 4*x^2)/((1 - 3*x)*(1 - x)^5). - Stefano Spezia, Jul 08 2025 [corrected by Jason Yuen, Jan 07 2026]
EXAMPLE
a(3) = 2 since the strings are 111 and 222.
a(4) = 18 since the strings are (number of permutations in parentheses): 1111 (1), 1112 (4), 1110 (4), 1222 (4), 0222 (4), 2222 (1).
MATHEMATICA
LinearRecurrence[{8, -25, 40, -35, 16, -3}, {0, 0, 0, 2, 18, 102}, 30] (* Paolo Xausa, Jan 07 2026 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Enrique Navarrete, Jul 08 2025
EXTENSIONS
Data corrected by Paolo Xausa, Jan 07 2026
STATUS
approved
