OFFSET
1,3
COMMENTS
XOR is the binary exclusive-or operator.
a(1)=0 for compatibility with similar sequences, and because 0 and 1 are not primes.
Note the sequence s(n)-a(n), where s(n)=A298816(n) is the binary XOR of all n-bit squares, begins: 1, -1, 2, 3, -14, -38, -87, -175, -20, -230, -1258, -2352, 3819, 9957, -1525, -9925, 31932, 21654, 264124, 226521, 405022, 2495526, 944510, 8579700, 15679080, 49342536, -35092149, -19209773, -131473914. The distribution of negative and positive terms does not look random: runs of negative terms are followed by runs of positive terms.
LINKS
Lars Blomberg, Table of n, a(n) for n = 1..41
EXAMPLE
There are two 4-bit primes, namely 11 and 13. a(4) = (11 XOR 13) = 6.
PROG
(Python)
from sympy import nextprime
n = x = L = 2
print('0', end=', ')
while L < 27:
nextn = nextprime(n)
if (nextn ^ n) > n: # if lengths of binary representations are different
print(str(x), end=', ')
x = 0
prevL = L
L = len(bin(nextn))-2
for j in range(prevL, L-1): print('0', end=', ')
n = nextn
x ^= n
(PARI) a(n) = {my(x = 0); for (k=2^(n-1), 2^n-1, if (isprime(k), x = bitxor(x, k)); ); x; } \\ Michel Marcus, Jan 27 2018
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Alex Ratushnyak, Jan 26 2018
EXTENSIONS
a(30)-a(34) from Lars Blomberg, Nov 10 2018
STATUS
approved