%I #42 Sep 08 2022 08:45:08
%S 0,1,4,6,10,13,18,22,28,33,40,46,54,61,70,78,88,97,108,118,130,141,
%T 154,166,180,193,208,222,238,253,270,286,304,321,340,358,378,397,418,
%U 438,460,481,504,526,550,573,598,622,648,673,700,726,754,781,810,838
%N Expansion of (x + b*x^2 - b*x^3)/((1 - x^2)*(1 - x)^2) with b=2.
%H Harvey P. Dale, <a href="/A079524/b079524.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (2,0,-2,1).
%F G.f.: (x + 2*x^2 - 2*x^3) / ((1 - x)^2 * (1 - x^2)).
%F a(n) = a(n-2)+n (mod a(n-1)+n) with n>=2 and initial values (1, 1).
%F a(n) = 2*a(n-1) - 2*a(n-3) + a(n-4), a(0)=0, a(1)=1, a(2)=4, a(3)=6. - _Harvey P. Dale_, Apr 20 2015
%F a(n) = (2*n*(n+6)-3*(1-(-1)^n))/8. - _Luce ETIENNE_, Jun 05 2015
%e G.f. = x + 4*x^2 + 6*x^3 + 10*x^4 + 13*x^5 + 18*x^6 + 22*x^7 + 28*x^8 + 33*x^9 + ...
%e Here b=2; a(0)=a(1)=1. a(2)= a(0)+2 (mod a(1)+2) = 3 (mod 3) =0 a(3)= a(1)+3 (mod a(2)+3) = 4 (mod 3) =1 a(4)= a(2)+4 (mod a(3)+4) = 4 (mod 5) =4 etc... we get 6, 13, 18, ...
%p a:= n-> (Matrix([[4,1,0,-2]]). Matrix(4, (i,j)-> if (i=j-1) then 1 elif j=1 then [2,0,-2,1][i] else 0 fi)^n)[1,4]: seq(a(n), n=1..60); # _Alois P. Heinz_, Aug 06 2008
%t b = 2; aa = {1, 1}; Do[AppendTo[aa, Mod[ aa[[ -2]] + n, aa[[ -1]] + n]], {n, b, 50}]; Drop[aa, 2]
%t CoefficientList[Series[(x+2*x^2-2*x^3)/((1-x)^2*(1-x^2)),{x,0,60}],x]
%t LinearRecurrence[{2,0,-2,1},{0,1,4,6},50] (* _Harvey P. Dale_, Apr 20 2015 *)
%o (PARI) my(x='x+O('x^50)); concat([0], Vec( (x+2*x^2-2*x^3)/((1-x)^2*(1- x^2)) )) \\ _G. C. Greubel_, Jan 15 2019
%o (Magma) m:=50; R<x>:=PowerSeriesRing(Integers(), m); [0] cat Coefficients(R!( (x+2*x^2-2*x^3)/((1-x)^2*(1- x^2)) )); // _G. C. Greubel_, Jan 15 2019
%o (Sage) ((x+2*x^2-2*x^3)/((1-x)^2*(1- x^2))).series(x, 50).coefficients(x, sparse=False) # _G. C. Greubel_, Jan 15 2019
%o (GAP) a:=[0,1,4,6];; for n in [5..50] do a[n]:=2*a[n-1]-2*a[n-3]+a[n-4]; od; a; # _G. C. Greubel_, Jan 15 2019
%Y Cf. A024206 and A078126.
%K easy,nonn
%O 0,3
%A _Carlos Alves_, Jan 21 2003