close
login
A360509
Number of words of length n over the alphabet [A-Z] that do not contain the string CAT.
1
1, 26, 676, 17575, 456924, 11879348, 308845473, 8029525374, 208755780376, 5427341444303, 141102848026504, 3668465292908728, 95374670274182625, 2479600324280721746, 64465939966005856668, 1676019064445878090743, 43574016075268549637572, 1132859952017016284720204
OFFSET
0,2
LINKS
Herbert S. Wilf, The Editor's Corner: Strings, Substrings, and the 'Nearest Integer' Function, The Amer. Math. Monthly, Vol. 94, No. 9 (1987), pp. 855-860.
FORMULA
a(0)=1, a(1)=26, a(2) = 26^2; thereafter, a(n) = 26*a(n-1) - a(n-3).
G.f.: 1/(1 - 26*x + x^3). - Elmo R. Oliveira, May 12 2026
EXAMPLE
At length 3, only one word (CAT) is excluded, so a(3) = 26^3 - 1 = 17575.
MAPLE
f:=proc(n, A) option remember;
if n<0 then 0 elif n=0 then 1 else A*f(n-1, A) - f(n-3, A); fi;
end;
[seq(f(n, 26), n=0..25)];
MATHEMATICA
f[n_, A_] := f[n, A] = Which[n < 0, 0, n == 0, 1, True, A*f[n-1, A] - f[n-3, A]];
Table[f[n, 26], {n, 0, 25}] (* Jean-François Alcover, Apr 14 2023, after Maple code *)
(* Alternative: *)
LinearRecurrence[{26, 0, -1}, {1, 26, 26^2}, 20] (* Harvey P. Dale, Dec 02 2023 *)
CROSSREFS
Sequence in context: A218063 A206695 A171300 * A188697 A188696 A009970
KEYWORD
nonn,easy,changed
AUTHOR
N. J. A. Sloane, Feb 24 2023
STATUS
approved