OFFSET
0,4
COMMENTS
First differences are -1, 2, 3, -4, 5, 6, -7, 8, 9, -10, 11, 12, ... - N. J. A. Sloane, May 20 2019
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 0..20000
Ilya Gutkovskiy, Graphs of first N terms for various values of N
Index entries for linear recurrences with constant coefficients, signature (1,0,2,-2,0,-1,1).
FORMULA
G.f.: x*(-1 + 2*x + 3*x^2 - 2*x^3 + x^4)/((1 - x)^3*(1 + x + x^2)^2).
a(n) = Sum_{k = 0..n} (-1)^(k mod 3)*k.
a(n) = Sum_{k = 0..n} -(-1)^A010882(k)*k.
From G. C. Greubel, Feb 03 2016: (Start)
a(n+7) = a(n+6) + 2*a(n+4) - 2*a(n+3) - a(n+1) + a(n).
E.g.f.: (1/18)*exp(-x/2)*((3*x^2+6*x-4)*exp(3*x/2) + 4*(1-3*x)*cos(sqrt(3)*x/2) - 4*sqrt(3)*(1+x)*sin(sqrt(3)*x/2)). (End)
EXAMPLE
a(0) = 0;
a(1) = 0 - 1 = -1;
a(2) = 0 - 1 + 2 = 1;
a(3) = 0 - 1 + 2 + 3 = 4;
a(4) = 0 - 1 + 2 + 3 - 4 = 0;
a(5) = 0 - 1 + 2 + 3 - 4 + 5 = 5;
a(6) = 0 - 1 + 2 + 3 - 4 + 5 + 6 = 11;
a(7) = 0 - 1 + 2 + 3 - 4 + 5 + 6 - 7 = 4;
a(8) = 0 - 1 + 2 + 3 - 4 + 5 + 6 - 7 + 8 = 12;
a(9) = 0 - 1 + 2 + 3 - 4 + 5 + 6 - 7 + 8 + 9 = 21, etc.
MATHEMATICA
Table[Sum[(-1)^Mod[k, 3] k, {k, 0, n}], {n, 0, 65}]
LinearRecurrence[{1, 0, 2, -2, 0, -1, 1}, {0, -1, 1, 4, 0, 5, 11}, 65]
CoefficientList[Series[x (1 -2 x -3 x^2 +2 x^3 -x^4)/(x^7 -x^6 -2 x^4 + 2 x^3 +x -1), {x, 0, 70}], x] (* Vincenzo Librandi, Jan 13 2016 *)
PROG
(PARI) Vec(x*(1-2*x-3*x^2+2*x^3-x^4)/(x^7-x^6-2*x^4+2*x^3+x-1) + O(x^100)) \\ Altug Alkan, Jan 25 2016
(Magma)
A267313:= func< n | (&+[(-1)^(k mod 3)*k : k in [0..n]]) >;
[A267313(n): n in [0..70]]; // G. C. Greubel, Sep 18 2024
(SageMath)
def A267313(n): return sum((-1)^(k%3)*k for k in range(n+1))
[A267313(n) for n in range(71)] # G. C. Greubel, Sep 18 2024
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Ilya Gutkovskiy, Jan 13 2016
STATUS
approved