OFFSET
0,5
COMMENTS
a(n) is the number of words of length n defined on 4 letters where two of the letters are used at least twice.
LINKS
Index entries for linear recurrences with constant coefficients, signature (16,-105,362,-692,696,-288).
FORMULA
a(n) = 4^n - 2*3^(n-1)*(n+3) + 2^(n-2)*(n^2+3*n+4).
E.g.f. exp(2*x)*(exp(x)-x-1)^2.
G.f.: 2*x^4*(3 - 8*x)/((1 - 3*x)^2*(1 - 2*x)^3*(1 - 4*x)). - Stefano Spezia, Mar 03 2025
EXAMPLE
For n=5 the 80 words that use 0 and 1 at least twice are 00111 (10 of this type), 00011 (10 of this type), 00112 (30 of this type), 00113 (30 of this type).
MATHEMATICA
LinearRecurrence[{16, -105, 362, -692, 696, -288}, {0, 0, 0, 0, 6, 80}, 25] (* Stefano Spezia, Mar 03 2025 *)
PROG
(Python)
def A381646(n): return ((1<<n+2)+n*(n+3)+4<<n-3)-(n+3)*3**(n-1)<<1 if n>2 else 0 # Chai Wah Wu, Mar 15 2025
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Enrique Navarrete, Mar 03 2025
STATUS
approved
