OFFSET
1,2
LINKS
Muniru A Asiru, Table of n, a(n) for n = 1..2000
Index entries for linear recurrences with constant coefficients, signature (1,4,-4,-6,6,4,-4,-1,1).
FORMULA
a(n) = a(n-1) + {[1-(-1)^n]/2}*n^3 + {[1+(-1)^n]/2}*n, with a(1)=1.
From R. J. Mathar, Feb 22 2009: (Start)
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).
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)
MAPLE
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
MATHEMATICA
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*)
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 *)
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 *)
PROG
(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
(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
(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
CROSSREFS
KEYWORD
nonn
AUTHOR
Artur Jasinski, May 12 2008
STATUS
approved