%I #62 Oct 29 2024 12:23:35
%S 1,2,3,5,6,9,10,14,15,20,21,27,28,35,36,44,45,54,55,65,66,77,78,90,91,
%T 104,105,119,120,135,136,152,153,170,171,189,190,209,210,230,231,252,
%U 253,275,276,299,300,324,325,350,351,377,378,405,406,434,435,464,465
%N Number of partitions of n in which any two parts differ by at most 2.
%C Equals row sums of triangle A177991. - _Gary W. Adamson_, May 16 2010
%C Positive numbers that are either triangular (A000217) or triangular minus 1 (A000096). - _Jon E. Schoenfield_, Jun 12 2010
%H Alois P. Heinz, <a href="/A117142/b117142.txt">Table of n, a(n) for n = 1..1000</a>
%H Jonathan Bloom and Nathan McNew, <a href="https://arxiv.org/abs/1908.03953">Counting pattern-avoiding integer partitions</a>, arXiv:1908.03953 [math.CO], 2019.
%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (1,2,-2,-1,1).
%F G.f.: Sum_{k>=1} x^k/((1 - x^k)*(1 - x^(k + 1))*(1 - x^(k + 2))). More generally, the g.f. of the number of partitions in which any two parts differ by at most b is Sum_{k>=1} (x^k/(Product_{j=k..k+b} 1 - x^j)).
%F a(n) = (2*n^2 + 10*n + 3 + (-1)^n * (2*n - 3))/16. - _Birkas Gyorgy_, Feb 20 2011
%F G.f.: (1 + x)/(1 - x)/(Q(0) - x^2 - x^3), where Q(k) = 1 + x^2 + x^3 + k*x*(1 + x^2) - x^2*(1 + x*(k + 2))*(1 + k*x)/Q(k+1) ; (continued fraction). - _Sergei N. Gladkovskii_, Jan 05 2014
%F G.f.: x*(1 + x - x^2)/((1 - x)^3*(1 + x)^2). - _Colin Barker_, Mar 05 2015
%F a(n) = Sum_{k=0..n-1} A152271(k). - _Jon Maiga_, Dec 21 2018
%F E.g.f.: (1/16)*( (3 + 2*x)*exp(-x) + (3 + 12*x + 2*x^2)*exp(x) ). - _G. C. Greubel_, Jul 18 2023
%F a(n) = A152919(n+1)/2. - _Ridouane Oudra_, Oct 29 2024
%e a(6) = 9 because we have
%e 1: [6],
%e 2: [4, 2],
%e 3: [3, 3],
%e 4: [3, 2, 1],
%e 5: [3, 1, 1, 1],
%e 6: [2, 2, 2],
%e 7: [2, 2, 1, 1],
%e 8: [2, 1, 1, 1, 1],
%e 9: [1, 1, 1, 1, 1, 1]
%e ([5,1] and [4,1,1] do not qualify).
%p g:=sum(x^k/(1-x^k)/(1-x^(k+1))/(1-x^(k+2)),k=1..75): gser:=series(g,x=0,70): seq(coeff(gser,x^n),n=1..65); with(combinat): for n from 1 to 7 do P:=partition(n): A:={}: for j from 1 to nops(P) do if P[j][nops(P[j])]-P[j][1]<3 then A:=A union {P[j]} else A:=A fi od: print(A); od: # this program yields the partitions
%t Table[Count[IntegerPartitions[n], _?(Max[#] - Min[#] <= 2 &)], {n, 30}] (* _Birkas Gyorgy_, Feb 20 2011 *)
%t Table[(2*n^2 +10*n +3 +(-1)^n*(2*n-3))/16, {n,30}] (* _Birkas Gyorgy_, Feb 20 2011 *)
%t Table[Sum[If[EvenQ[k], 1, (k+1)/2], {k,0,n}], {n,0,60}] (* _Jon Maiga_, Dec 21 2018 *)
%o (PARI) Vec(x*(x^2-x-1)/((x-1)^3*(x+1)^2) + O(x^100)) \\ _Colin Barker_, Mar 05 2015
%o (GAP) List([1..60],n->(2*n^2+10*n+3+(-1)^n*(2*n-3))/16); # _Muniru A Asiru_, Dec 21 2018
%o (Magma) [(2*n*(n+5) +3 +(-1)^n*(2*n-3))/16: n in [1..60]]; // _G. C. Greubel_, Jul 18 2023
%o (SageMath) [(2*n*(n+5) +3 +(-1)^n*(2*n-3))/16 for n in range(1,61)] # _G. C. Greubel_, Jul 18 2023
%Y Cf. A000096, A000217, A117143, A152271, A177991, A152919.
%Y Column k=2 of A194621. - _Alois P. Heinz_, Oct 17 2012
%K nonn,easy,changed
%O 1,2
%A _Emeric Deutsch_, Feb 27 2006