OFFSET
1,2
LINKS
Indranil Ghosh, Table of n, a(n) for n = 1..25000
FORMULA
G.f.: x*(1 + 2*x + 6*x^2 - 2*x^3 + x^4)/((1-x^2)*(1-x^4)).
EXAMPLE
a(2) = 1 XOR 3 = 2; a(3) = 1 XOR 3 XOR 5 = 7; a(4) = 1 XOR 3 XOR 5 XOR 7 = 0.
MAPLE
a := proc(n) local u, b, w, k;
u := 1; w := 1; b := true;
for k from 2 to n do
u := u + 2;
w := u + `if`(b, -w, +w);
b := not b;
od; w end:
seq(a(n), n=1..95); # Peter Luschny, Dec 31 2014
MATHEMATICA
With[{c=Range[1, 201, 2]}, Table[BitXor@@Take[c, n], {n, 100}]] (* Harvey P. Dale, Nov 19 2011 *)
PROG
(PARI) a(n)=if(n==1, 1, bitxor(a(n-1), 2*n-1))
(PARI) Vec((1 + 2*x + 6*x^2 - 2*x^3 + x^4)/(1-x^2)/(1-x^4)+O(x^99)) \\ Charles R Greathouse IV, Dec 31 2014
(Python)
from operator import xor
from functools import reduce
def A199398(n): return reduce(xor, range(1, n<<1, 2)) # Chai Wah Wu, Jul 09 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Paul D. Hanna, Nov 05 2011
STATUS
approved