login
Expansion of (1+x+2*x^3)/((1-x)*(1-x^2)).
2

%I #29 Sep 08 2022 08:45:00

%S 1,2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39,42,43,46,

%T 47,50,51,54,55,58,59,62,63,66,67,70,71,74,75,78,79,82,83,86,87,90,91,

%U 94,95,98,99,102,103,106,107,110,111,114,115,118,119,122

%N Expansion of (1+x+2*x^3)/((1-x)*(1-x^2)).

%H G. C. Greubel, <a href="/A053438/b053438.txt">Table of n, a(n) for n = 0..5000</a>

%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,1,-1).

%F a(n) = 2*n -(1+(-1)^n)/2 if n>=1. - _Frank Ellermann_, Feb 12 2002

%F a(n) = A042964(n), n>0. - _R. J. Mathar_, Oct 13 2008

%F a(n) = A014601(n) - 1 for n>0. - _Hugo Pfoertner_, Oct 26 2020

%p A053438 := proc(n)

%p if n > 0 then

%p 2*n -(1+(-1)^n)/2 ;

%p else

%p 1 ;

%p end if

%p end proc:

%p seq(A053438(n),n=0..30) ; # _R. J. Mathar_, Oct 27 2020

%t CoefficientList[Series[(1+x+2*x^3)/((1-x)*(1-x^2)), {x, 0, 50}], x] (* or *) Join[{1}, LinearRecurrence[{1,1,-1}, {2,3,6}, 50]] (* _G. C. Greubel_, May 26 2018 *)

%o (PARI) a(n)=abs(n\2*4+n%2*3-1) \\ _Charles R Greathouse IV_, Dec 08 2011

%o (Magma) I:=[2,3,6]; [1] cat [n le 3 select I[n] else Self(n-1) +Self(n-2) -Self(n-3): n in [1..30]]; // _G. C. Greubel_, May 26 2018

%Y Cf. A010684 (first differences), A263511 (partial sums).

%K nonn,easy

%O 0,2

%A _N. J. A. Sloane_, Jan 12 2000