OFFSET
1,2
COMMENTS
Consider the partitions of 2n into two parts: When n is odd, a(n) gives the total sum of the even numbers from the smallest parts and the odd numbers from the largest parts of these partitions. When n is even, a(n) gives the total sum of the odd numbers from the smallest parts and the even numbers from the largest parts (see example).
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (1,2,-2,-1,1).
FORMULA
a(n) = (4*n^2 - 1 - (2*n - 1)*(-1)^n) / 4.
G.f.: x*(1+2*x+5*x^2)/((1+x)^2*(1-x)^3). - Robert Israel, Jul 25 2014
a(n) = (2*n-1)*(n-floor(n/2)). - Wesley Ivan Hurt, Jan 10 2017
a(n) = n^2 + Sum_{k=1..n-1} (-1)^k*k for n>1. Example: for n=5, a(5) = 5^2 + (4 - 3 + 2 - 1) = 27. - Bruno Berselli, May 23 2018
E.g.f.: (1/2)*(x*(2*x+3)*cosh(x) + (2*x^2+x-1)*sinh(x)). - G. C. Greubel, Mar 14 2024
a(n) = a(n-1) + 2*a(n-2) - 2*a(n-3) - a(n-4) + a(n-5). - Wesley Ivan Hurt, Jun 20 2024
EXAMPLE
a(3) = 10; The partitions of 2*3 = 6 into two parts are: (5,1), (4,2), (3,3). Since 3 is odd, we sum the even numbers from the smallest parts together with the odd numbers from the largest parts to get: (2) + (3+5) = 10.
a(4) = 14; The partitions of 4*2 = 8 into two parts are: (7,1), (6,2), (5,3), (4,4). Since 4 is even, we sum the odd numbers from the smallest parts together with the even numbers from the largest parts to get: (1+3) + (4+6) = 14.
MATHEMATICA
Table[n^2 - Floor[n/2] (-1)^n, {n, 50}]
CoefficientList[Series[(1 + 2 x + 5 x^2)/((1 + x)^2 (1 - x)^3), {x, 0, 50}], x] (* Vincenzo Librandi, Jul 25 2014 *)
PROG
(Magma) [n^2-Floor(n/2)*(-1)^n : n in [1..50]];
(SageMath) [n^2-(-1)^n*(n//2) for n in range(1, 71)] # G. C. Greubel, Mar 14 2024
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Wesley Ivan Hurt, Jul 24 2014
STATUS
approved