A126084 a(n) = XOR of first n primes.
0, 2, 1, 4, 3, 8, 5, 20, 7, 16, 13, 18, 55, 30, 53, 26, 47, 20, 41, 106, 45, 100, 43, 120, 33, 64, 37, 66, 41, 68, 53, 74, 201, 64, 203, 94, 201, 84, 247, 80, 253, 78, 251, 68, 133, 64, 135, 84, 139, 104, 141, 100, 139, 122, 129, 384, 135, 394, 133, 400, 137, 402, 183, 388, 179
Offset: 0
Examples
a(4) = 3 because ((2 XOR 3) XOR 5) XOR 7 = (1 XOR 5) XOR 7 = 4 XOR 7 = 3 [Or, in base 2] ((10 XOR 11) XOR 101) XOR 111 = (1 XOR 101) XOR 111 = 100 XOR 111 = 11
Links
- Franklin T. Adams-Watters, Table of n, a(n) for n = 0..10000
Programs
-
Mathematica
Module[{nn=70,prs},prs=Prime[Range[nn]];Table[BitXor@@Take[prs,n],{n,0,nn}]] (* Harvey P. Dale, Jun 23 2016 *)
-
PARI
al(n)=local(m);vector(n,k,m=bitxor(m,prime(k))) /* Produces a vector without a(0) = 0; Franklin T. Adams-Watters, Jul 17 2011 */
-
PARI
v=primes(300); for(i=2,#v,v[i]=bitxor(v[i],v[i-1])); concat(0, v) \\ Charles R Greathouse IV, Aug 26 2014
-
PARI
q=0; forprime(p=2, 313, print1(q, ","); q=bitxor(q, p)) /* Klaus Brockhaus, Mar 06 2007; adapted by Rémy Sigrist, Oct 23 2017 */
-
Python
from operator import xor from functools import reduce from sympy import primerange, prime def A126084(n): return reduce(xor,primerange(2,prime(n)+1)) if n else 0 # Chai Wah Wu, Jul 09 2022
Formula
a(0) = 0; a(n) = a(n-1) XOR prime(n).
Extensions
More terms from Klaus Brockhaus, Mar 06 2007
Edited by N. J. A. Sloane, Oct 22 2017 (merging old entry A193174 with this)
Edited by Rémy Sigrist, Oct 23 2017
Comments