We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Number Binary repr. xor from 1 to n A(1)^A(2)...^A(n)
0 0000 0000 0000=0
1 0001 0001 0001=1
2 0010 0011 0010=2
3 0011 0000 0010=2
4 0100 0100 0110=6
5 0101 0001 0111=7
6 0110 0111 0000=0
7 0111 0000 0000=0
from above we can deduce that G is periodic function with period of 8
now for a==0 or a==1 value is x
for a==2 or a==3 value is 2
for a==4 or a==5 value is x+2
for a==6 or a==7 value is 0
For better undestanding how to calculate xor of 1 to n efficiently please refer this link:-xor from 1 to n
here is my solution
Xor-sequence
You are viewing a single comment's thread. Return to all comments →
I am explaining how G function is working.
Number Binary repr. xor from 1 to n A(1)^A(2)...^A(n)
from above we can deduce that G is periodic function with period of 8 now for a==0 or a==1 value is x for a==2 or a==3 value is 2 for a==4 or a==5 value is x+2 for a==6 or a==7 value is 0 For better undestanding how to calculate xor of 1 to n efficiently please refer this link:-xor from 1 to n here is my solution