%I #24 Sep 22 2023 05:22:20
%S 1,3,9,27,78,222,618,1686,4512,11856,30624,77856,195072,482304,
%T 1178112,2846208,6807552,16134144,37920768,88449024,204865536,
%U 471465984,1078591488,2454061056,5555355648,12516851712,28078768128,62732107776,139619991552,309640298496,684409749504,1508036837376,3313030397952
%N Number of ternary words of length n avoiding the pattern 11-11.
%H Colin Barker, <a href="/A241574/b241574.txt">Table of n, a(n) for n = 0..1000</a>
%H Jair Taylor, <a href="https://doi.org/10.37236/3500">Counting Words with Laguerre Series</a>, Electron. J. Combin., 21 (2014), P2.1.
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (8,-24,32,-16).
%F G.f.: (1 - 5*x + 9*x^2 - 5*x^3 - 2*x^4 + 6*x^5 - 6*x^6 + 6*x^7)/ (1 - 8*x + 24*x^2 - 32*x^3 + 16*x^4).
%F a(n) = 3*2^(n-7)*(16 + 36*n - n^2 + n^3) for n > 3. - _Colin Barker_, Jun 06 2015
%F a(n) = 8*a(n-1) - 24*a(n-2) + 32*a(n-3) - 16*a(n-4) for n > 7. - _Colin Barker_, Jun 06 2015
%F E.g.f.: (1/16)*(10 + 9*x + 3*x^2 + x^3 + (6 + 27*x + 3*x^2 + 3*x^3)*exp(2*x)). - _G. C. Greubel_, Sep 22 2023
%t LinearRecurrence[{8,-24,32,-16}, {1,3,9,27,78,222,618,1686}, 41] (* _G. C. Greubel_, Sep 22 2023 *)
%o (PARI) Vec((6*x^7-6*x^6+6*x^5-2*x^4-5*x^3+9*x^2-5*x+1)/ (16*x^4-32*x^3+24*x^2-8*x+1) + O(x^100)) \\ _Colin Barker_, Jun 06 2015
%o (Magma)
%o A241574:= func< n | n le 3 select 3^n else 3*2^(n-7)*(16+36*n-n^2+n^3) >;
%o [A241574(n): n in [0..40]]; // _G. C. Greubel_, Sep 22 2023
%o (SageMath)
%o def A241574(n): return 3^n if (n<4) else 3*2^(n-7)*(16 +36*n -n^2 +n^3)
%o [A241574(n) for n in range(41)] # _G. C. Greubel_, Sep 22 2023
%K nonn,easy
%O 0,2
%A _N. J. A. Sloane_, Apr 26 2014