This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A239791 #39 Aug 03 2020 01:29:49 %S A239791 1,1,2,4,7,14,28,54,105,205,399,777,1514,2949,5744,11189,21795,42454, %T A239791 82696,161083,313772,611194,1190540,2319043,4517245,8799105,17139705, %U A239791 33386292,65032887,126677032,246753161,480648477,936251262,1823716224,3552402011,6919695006,13478817664,26255279382,51142445325 %N A239791 Number of compositions of n with no consecutive 2's. %H A239791 Vincenzo Librandi, <a href="/A239791/b239791.txt">Table of n, a(n) for n = 0..1000</a> %H A239791 <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (2,-1,2,-1,1). %F A239791 G.f.: (1 + x^2)/(1 - (2*x^5/(1 - x) + x + x^4 + 2*x^3)) = (x - 1)*(1 + x^2) / (-1 + 2*x - x^2 + 2*x^3 - x^4 + x^5). %F A239791 Generally, for fixed integer k>=1, the g.f. for the number of compositions with no consecutive k's: (1 + x^k)/(1 - (2*x^(2*k + 1)/(1-x) + x^(2*k) + Sum_{j=1..k-1} x^j + Sum{j=k+1..2*k-1} 2*x^j)). %F A239791 Another way to write G. Critzer's general g.f. above: 1/((1 - 2*x)/(1 - x) + x^(2*k)/(1 + x^k)). - _Petros Hadjicostas_, Dec 03 2017 %F A239791 Recurrence: a(n) = 2*a(n-1) - a(n-2) + 2*a(n-3) - a(n-4) + a(n-5). - _Petros Hadjicostas_, Aug 02 2020 %e A239791 a(5) = 14 because there are 16 compositions of 5, but we don't count 2+2+1 and 1+2+2. %t A239791 nn=30;k=2;CoefficientList[Series[(1+x^k)/(1-(2x^(2k+1)/(1-x)+x^(2k)+Sum[x^j,{j,1,k-1}]+Sum[2x^j,{j,k+1,2k-1}])),{x,0,nn}],x] %t A239791 CoefficientList[Series[(1 + x^2)/(1 - (2 x^5/(1 - x) + x + x^4 + 2 x^3)), {x, 0, 50}], x] (* _Vincenzo Librandi_, Mar 29 2014 *) %o A239791 (PARI) Vec( (1 + x^2)/(1 - (2*x^5/(1-x) + x + x^4 + 2*x^3)) + O(x^66) ) \\ _Joerg Arndt_, Mar 27 2014 %Y A239791 Cf. A000213 (compositions with no consecutive 1's), A003242. %K A239791 nonn,easy %O A239791 0,3 %A A239791 _Geoffrey Critzer_, Mar 26 2014