OFFSET
0,4
LINKS
Colin Barker, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (1,-2,2,-1,1).
FORMULA
a(4t)=0, a(4t+1)=-(4t+1), a(4t+2)=1, a(4t+3)=4t+4.
From Colin Barker, Aug 13 2019: (Start)
G.f.: -x*(1 - 2*x - x^2) / ((1 - x)*(1 + x^2)^2).
a(n) = a(n-1) - 2*a(n-2) + 2*a(n-3) - a(n-4) + a(n-5) for n>4.
a(n) = 1/2 - (1/4 - i/4)*((-i)^n+i^(1+n)) - (1/2)*i*((-i)^n-i^n)*(1+n) where i=sqrt(-1).
(End)
MAPLE
t:=0;
a:=[t]; M:=100;
for i from 1 to M do
if (t mod 2) = 1 then t:=t+i else t:=t-i; fi;
a:=[op(a), t]; od:
a;
MATHEMATICA
nxt[{n_, a_}]:={n+1, If[OddQ[a], a+n+1, a-n-1]}; NestList[nxt, {0, 0}, 80][[All, 2]] (* Harvey P. Dale, Sep 26 2021 *)
PROG
(PARI) concat(0, Vec(-x*(1 - 2*x - x^2) / ((1 - x)*(1 + x^2)^2) + O(x^40))) \\ Colin Barker, Aug 13 2019
CROSSREFS
KEYWORD
sign,easy
AUTHOR
N. J. A. Sloane, Aug 10 2019
STATUS
approved
