Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #15 Jan 02 2024 09:01:39
%S 1,3,30,34,159,165,508,516,1245,1255,2586,2598,4795,4809,8184,8200,
%T 13113,13131,19990,20010,29271,29293,41460,41484,57109,57135,76818,
%U 76846,101235,101265,131056,131088,167025,167059,209934,209970,260623
%N a(1)=1, a(n) = a(n-1) + n^3 if n odd, a(n) = a(n-1) + n^1 if n is even.
%H Muniru A Asiru, <a href="/A140153/b140153.txt">Table of n, a(n) for n = 1..2000</a>
%H <a href="/index/Rec#order_09">Index entries for linear recurrences with constant coefficients</a>, signature (1,4,-4,-6,6,4,-4,-1,1).
%F a(n) = a(n-1) + {[1-(-1)^n]/2}*n^3 + {[1+(-1)^n]/2}*n, with a(1)=1.
%F From _R. J. Mathar_, Feb 22 2009: (Start)
%F a(n) = a(n-1) + 4*a(n-2) - 4*a(n-3) - 6*a(n-4) + 6*a(n-5) + 4*a(n-6) - 4*a(n-7) - a(n-8) + a(n-9).
%F G.f.: x*(1+2*x+23*x^2-4*x^3+23*x^4+2*x^5+x^6)/((1+x)^4*(1-x)^5). (End)
%p a:=proc(n) option remember: if n=1 then 1 elif modp(n,2)<>0 then procname(n-1)+n^3 else procname(n-1)+n; fi: end; seq(a(n),n=1..40); # _Muniru A Asiru_, Jul 12 2018
%t a = {}; r = 3; s = 1; Do[k = 0; Do[k = k + (Sin[Pi m/2]^2) m^r + (Cos[Pi m/2]^2) m^s, {m, 1, n}]; AppendTo[a, k], {n, 1, 100}]; a (*Artur Jasinski*)
%t CoefficientList[Series[x*(1+2*x+23*x^2-4*x^3+23*x^4+2*x^5+x^6)/((1+x)^4*(1-x)^5), {x,0,30}], x] (* _G. C. Greubel_, Jul 12 2018 *)
%t nxt[{n_,a_}]:={n+1,If[EvenQ[n],a+(n+1)^3,a+n+1]}; NestList[nxt,{1,1},40][[All,2]] (* or *) LinearRecurrence[{1,4,-4,-6,6,4,-4,-1,1},{1,3,30,34,159,165,508,516,1245},40] (* _Harvey P. Dale_, Aug 26 2021 *)
%o (PARI) x='x+O('x^30); Vec(x*(1+2*x+23*x^2-4*x^3+23*x^4+2*x^5+x^6)/((1+x)^4*(1-x)^5)) \\ _G. C. Greubel_, Jul 12 2018
%o (Magma) m:=30; R<x>:=PowerSeriesRing(Integers(), m); Coefficients(R!(x*(1+2*x+23*x^2-4*x^3+23*x^4+2*x^5+x^6)/((1+x)^4*(1-x)^5))); // _G. C. Greubel_, Jul 12 2018
%o (GAP) a:=[1];; for n in [2..40] do a[n]:=a[n-1]+((1-(-1)^n)/2)*n^3+((1+(-1)^n)/2)*n; od; a; # _Muniru A Asiru_, Jul 12 2018
%Y Cf. A000027, A000217, A000330, A000537, A000538, A000539, A136047, A140113.
%K nonn
%O 1,2
%A _Artur Jasinski_, May 12 2008