Bit Magic Xor Help

Can You please tell proof of second method

1 Like

The cumulative xor of numbers 1...N shows this wonderful property where it repeats according to the pattern mentioned in the article. I guess the only explanation I can think of is that the bits get cancelled when (N+1)|4 and the rest just follows as:

0 \oplus x=x, \forall x \in \mathbb{B}

i.e.,

0 | 0
\oplus \oplus
0 | 1
\rule{0.6cm}{0.4pt}
0 | 1

Here’s another link with some more explanation regarding the topic. I’m not sure whether you’ll find a rigorous proof of this though. Hope this helps you. :slightly_smiling_face:

1 Like