login
a(n) = 1*2 - 3*4 + 5*6 - 7*8 + 9*10 - 11*12 + 13*14 - ... + (up to n).
9

%I #23 Oct 05 2018 08:48:19

%S 1,2,-1,-10,-5,20,13,-36,-27,54,43,-78,-65,104,89,-136,-119,170,151,

%T -210,-189,252,229,-300,-275,350,323,-406,-377,464,433,-528,-495,594,

%U 559,-666,-629,740,701,-820,-779,902,859,-990,-945,1080,1033,-1176,-1127

%N a(n) = 1*2 - 3*4 + 5*6 - 7*8 + 9*10 - 11*12 + 13*14 - ... + (up to n).

%C In general, for alternating sequences that multiply the first k natural numbers, and subtract/add the products of the next k natural numbers (preserving the order of operations up to n), we have a(n) = (-1)^floor(n/k) * Sum_{i=1..k-1} (1-sign((n-i) mod k)) * (Product_{j=1..i} (n-j+1)) + Sum_{i=1..n} (-1)^(floor(i/k)+1) * (1-sign(i mod k)) * (Product_{j=1..k} (i-j+1)). Here k=2.

%C An alternating version of A228958.

%H Colin Barker, <a href="/A319373/b319373.txt">Table of n, a(n) for n = 1..1000</a>

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

%F a(n) = (cos(n*Pi/2)*(1-n-n^2) + sin(n*Pi/2)*(1+3*n-n^2) - 1)/2.

%F From _Colin Barker_, Sep 18 2018: (Start)

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

%F a(n) = a(n-1) - 3*a(n-2) + 3*a(n-3) - 3*a(n-4) + 3*a(n-5) - a(n-6) + a(n-7) for n>7. (End)

%F a(n) = (-1 + (-1)^((n-1)*n/2))/2 + (-2 + (-1)^n)*(-1)^(n*(n+1)/2)*n/2 - (-1)^((n-1)*n/2)*n^2/2. - _Bruno Berselli_, Sep 25 2018

%e a(1) = 1;

%e a(2) = 1*2 = 2;

%e a(3) = 1*2 - 3 = -1;

%e a(4) = 1*2 - 3*4 = -10;

%e a(5) = 1*2 - 3*4 + 5 = -5;

%e a(6) = 1*2 - 3*4 + 5*6 = 20;

%e a(7) = 1*2 - 3*4 + 5*6 - 7 = 13;

%e a(8) = 1*2 - 3*4 + 5*6 - 7*8 = -36;

%e a(9) = 1*2 - 3*4 + 5*6 - 7*8 + 9 = -27;

%e a(10) = 1*2 - 3*4 + 5*6 - 7*8 + 9*10 = 54;

%e a(11) = 1*2 - 3*4 + 5*6 - 7*8 + 9*10 - 11 = 43;

%e a(12) = 1*2 - 3*4 + 5*6 - 7*8 + 9*10 - 11*12 = -78;

%e a(13) = 1*2 - 3*4 + 5*6 - 7*8 + 9*10 - 11*12 + 13 = -65;

%e a(14) = 1*2 - 3*4 + 5*6 - 7*8 + 9*10 - 11*12 + 13*14 = 104;

%e a(15) = 1*2 - 3*4 + 5*6 - 7*8 + 9*10 - 11*12 + 13*14 - 15 = 89; etc.

%t Table[(Cos[n Pi/2] (1 - n - n^2) + Sin[n Pi/2] (1 + 3 n - n^2) - 1)/2, {n, 50}]

%t a[n_] := (-1)^Floor[n/2] Sum[(1 - Sign[Mod[n - i, 2]]) Product[n - j + 1, {j, 1, i}], {i, 1, 1}] + Sum[(-1)^(Floor[i/2] + 1) (1 - Sign[Mod[i, 2]]) Product[i - j + 1, {j, 1, 2}], {i, 1, n}]; Array[a, 30] (* _Stefano Spezia_, Sep 23 2018 *)

%o (PARI) Vec(x*(1 + x - 6*x^3 - x^4 + x^5) / ((1 - x)*(1 + x^2)^3) + O(x^50)) \\ _Colin Barker_, Sep 18 2018

%Y Cf. A093361, A228958, A305189.

%Y For similar sequences, see: A001057 (k=1), this sequence (k=2), A319543 (k=3), A319544 (k=4), A319545 (k=5), A319546 (k=6), A319547 (k=7), A319549 (k=8), A319550 (k=9), A319551 (k=10).

%K sign,easy

%O 1,2

%A _Wesley Ivan Hurt_, Sep 17 2018