%I #27 Feb 22 2020 20:57:36
%S 0,0,1,52,2027,70226,2280825,71112600,2155562551,64005323902,
%T 1870809923477,54006556365476,1543466751232275,43746473462661450,
%U 1231293799939647601,34451045198171912752,959005856055827234927,26576960554539062120726,733650711461388661963725
%N Number of strings of length n, formed from the 26-letter English alphabet, which contain the substring xy.
%H G. C. Greubel, <a href="/A215595/b215595.txt">Table of n, a(n) for n = 0..700</a>
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (52,-677,26).
%F a(n) = 26*a(n-1) + 26^(n-2) - a(n-2).
%F a(n) = 52*a(n-1) - 677*a(n-2) + 26*a(n-3). - _Charles R Greathouse IV_, Aug 16 2012
%F G.f.: x/(1 - 52*x + 677*x^2 - 26*x^3). - _Alexander R. Povolotsky_, Aug 16 2012
%F a(n) = (1/168)*(13 +2*sqrt(42))^(-n)*(-(84+13*sqrt(42))*(13+2*sqrt(42))^(2*n) + 168*(338+52*sqrt(42))^n-84+13*sqrt(42)). - _Alexander R. Povolotsky_, Aug 16 2012
%F a(n) = Sum_{j=1..n} (-1)^(j+1) * B(n,j), where B(n,j) is the number of ways to place k occurrences of xy in a string of length n, and then choosing arbitrary letters for the n - 2k remaining positions. B(n,j) = product((n-i),i=j..(2*j-1)) / j! * 26^(n-2*j).
%e For n = 2, the only such string is xy. For n = 3, there are 26 strings of the form *xy and 26 of the form xy*. For n = 4, there are 26^2 of each of the forms xy**, *xy* and **xy, but we double count xyxy, so the answer for n=4 is 3*26^2 - 1 = 2027.
%t Join[{0}, CoefficientList[Series[x/(1 - 52*x + 677*x^2 - 26*x^3), {x, 0, 50}], x]] (* _G. C. Greubel_, Feb 26 2017 *)
%o (PARI) x='x+O('x^50); concat([0,0], Vec(x/(1 - 52*x + 677*x^2 - 26*x^3))) \\ _G. C. Greubel_, Feb 26 2017
%Y Cf. A186314 (same problem for ternary strings).
%K nonn,easy
%O 0,4
%A _David Kofoed Wind_, Aug 16 2012
|