login
a(n) = n^2 - (n-1)^2*(1 - (-1)^n)/8.
13

%I #15 Jan 31 2024 14:20:23

%S 0,1,4,8,16,21,36,40,64,65,100,96,144,133,196,176,256,225,324,280,400,

%T 341,484,408,576,481,676,560,784,645,900,736,1024,833,1156,936,1296,

%U 1045,1444,1160,1600,1281,1764,1408

%N a(n) = n^2 - (n-1)^2*(1 - (-1)^n)/8.

%C Partial sums are A129371.

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

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

%F a(n) = (1/8)*( (7*n^2 + 2*n - 1) + (-1)^n*(n-1)^2 ).

%F G.f.: x*(1 + 4*x + 5*x^2 + 4*x^3)/(1-x^2)^3.

%F E.g.f.: (1/4)*( x*(5+4*x)*cosh(x) - (1-4*x-3*x^2)*sinh(x) ). - _G. C. Greubel_, Jan 31 2024

%t Table[n^2-(n-1)^2 (1-(-1)^n)/8,{n,0,50}] (* _Harvey P. Dale_, Oct 22 2011 *)

%o (PARI) a(n)=n^2-(n-1)^2*(1-(-1)^n)/8 \\ _Charles R Greathouse IV_, Sep 28 2015

%o (Magma) [n^2 -(n-1)^2*(n mod 2)/4: n in [0..60]]; // _G. C. Greubel_, Jan 31 2024

%o (SageMath) [n^2 -(n-1)^2*(n%2)/4 for n in range(61)] # _G. C. Greubel_, Jan 31 2024

%Y Cf. A000567 (odd bisection), A016742 (even bisection), A129371.

%K easy,nonn

%O 0,3

%A _Paul Barry_, Apr 11 2007