A248960 Number of ternary words of length n in which all digits 0..2 occur in every 5 consecutive digits.
1, 3, 9, 27, 81, 150, 366, 870, 2022, 4686, 10974, 25614, 59742, 139398, 325350, 759198, 1771590, 4134126, 9647262, 22512342, 52533750, 122590422, 286071414, 667563054, 1557794622, 3635198310, 8482932318, 19795382454, 46193598486, 107795266974, 251546100558, 586996465758, 1369788083022
Offset: 0
Links
- Colin Barker, Table of n, a(n) for n = 0..1000
- Index entries for linear recurrences with constant coefficients, signature (1,2,2,2,-1,-1).
Programs
-
Mathematica
Join[{1,3,9,27,81},LinearRecurrence[{1,2,2,2,-1,-1},{150,366,870,2022,4686,10974},30]] (* Harvey P. Dale, Apr 04 2015 *)
-
PARI
Vec((1+2*x+4*x^2+10*x^3+28*x^4-8*x^5-14*x^6-6*x^8+3*x^10)/((1+x)*(1-2*x-2*x^3+x^5)) + O(x^30)) \\ Colin Barker, Oct 27 2016
Formula
G.f.: (1+2*x+4*x^2+10*x^3+28*x^4-8*x^5-14*x^6-6*x^8+3*x^10) / ((1+x)*(1-2*x-2*x^3+x^5)). - Colin Barker, Oct 27 2016
a(n) = a(n-1) + 2*a(n-2) + 2*a(n-3) + 2*a(n-4) - a(n-5) - a(n-6).
a(n) = A242317(n-4) * 6.
Extensions
Changed offset to 0. - N. J. A. Sloane, Jan 15 2015