OFFSET
0,3
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (0, 1, 0, 1, 0, -1).
FORMULA
a(n) = n + (-1)^n*a(n-1). - Vladeta Jovovic, Mar 13 2003
a(0)=0, a(4n+1)=1, a(4n+2)=4n+3, a(4n+3)=0, a(4n+4)=4n+4, n >= 0.
a(n) = f(n,0) with f(n,x) = x if n=0, otherwise f(n-1,x+n) if x is even, otherwise f(n-1,x-n). - Reinhard Zumkeller, Oct 09 2007
a(n) = abs(A077140(n)) for n > 0. - Reinhard Zumkeller, Oct 09 2007
G.f.: x*(1+3*x-x^2+x^3)/((1-x^4)*(1-x^2)). - Vincenzo Librandi, Oct 12 2013
a(n) = (1 + n + n*(-1)^n + (-1)^floor((n-1)/2))/2. - Wesley Ivan Hurt, May 08 2021
MATHEMATICA
an = 0; Reap[ For[i = 0, i <= 100, i++, an = BitXor[an, i]; Sow[an]]][[2, 1]] (* Jean-François Alcover, Oct 11 2013, translated from PARI *)
CoefficientList[Series[x (1 + 3 x - x^2 + x^3)/((1 - x^4) (1 - x^2)), {x, 0, 100}], x] (* Vincenzo Librandi, Oct 12 2013 *)
nxt[{n_, a_}]:={n+1, BitXor[n+1, a]}; NestList[nxt, {0, 0}, 70][[All, 2]] (* Harvey P. Dale, Mar 10 2019 *)
{#, 1, #+1, 0}[[1+Mod[#, 4]]]&/@Range[0, 100] (* Federico Provvedi, May 10 2021 *)
PROG
(PARI) print1(an=0); for( i=1, 100, print1(", ", an=bitxor(an, i))) \\ M. F. Hasler, Oct 20 2008
CROSSREFS
KEYWORD
nonn,base
AUTHOR
STATUS
approved