login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A199398 XOR of the first n odd numbers. 2

%I #23 Jul 10 2022 03:56:56

%S 1,2,7,0,9,2,15,0,17,2,23,0,25,2,31,0,33,2,39,0,41,2,47,0,49,2,55,0,

%T 57,2,63,0,65,2,71,0,73,2,79,0,81,2,87,0,89,2,95,0,97,2,103,0,105,2,

%U 111,0,113,2,119,0,121,2,127,0,129,2,135,0,137,2,143,0,145,2,151,0,153,2,159,0,161,2,167,0,169,2,175,0,177,2,183,0,185,2,191

%N XOR of the first n odd numbers.

%H Indranil Ghosh, <a href="/A199398/b199398.txt">Table of n, a(n) for n = 1..25000</a>

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

%e a(2) = 1 XOR 3 = 2; a(3) = 1 XOR 3 XOR 5 = 7; a(4) = 1 XOR 3 XOR 5 XOR 7 = 0.

%p a := proc(n) local u,b,w,k;

%p u := 1; w := 1; b := true;

%p for k from 2 to n do

%p u := u + 2;

%p w := u + `if`(b, -w, +w);

%p b := not b;

%p od; w end:

%p seq(a(n), n=1..95); # _Peter Luschny_, Dec 31 2014

%t With[{c=Range[1,201,2]},Table[BitXor@@Take[c,n],{n,100}]] (* _Harvey P. Dale_, Nov 19 2011 *)

%o (PARI) a(n)=if(n==1,1,bitxor(a(n-1),2*n-1))

%o (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

%o (Python)

%o from operator import xor

%o from functools import reduce

%o def A199398(n): return reduce(xor,range(1,n<<1,2)) # _Chai Wah Wu_, Jul 09 2022

%Y Cf. A126084 (XOR of first n primes).

%K nonn,easy

%O 1,2

%A _Paul D. Hanna_, Nov 05 2011

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 16:40 EDT 2024. Contains 371916 sequences. (Running on oeis4.)