Is there a theorem related to 0 xor 1 xor 2 xor ... xor 1000000 = 1000000? While testing for a program, I found that 
0 xor 1 xor 2 xor ... xor 1000000 = 1000000

and it is true for the numbers in this form except for 10:
1 1 true
10 11 false
100 100 true
1000 1000 true
10000 10000 true
100000 100000 true
1000000 1000000 true
10000000 10000000 true
100000000 100000000 true
1000000000 1000000000 true

(the true means it follows the rule and false means it doesn't).
Is there any theorem that is related to this? And what is so special about the number 10?
The program in Ruby if you are interested to try out:
n = 1
10.times do
   r = (0..n).inject(:^)
   puts "#{n} #{r} #{n == r}" 
   n *= 10
end

 A: You have noticed what I would consider an incidental pattern.  The actual underlying pattern comes from the fact that for any non-negative integer $k,$ $$(4k) \oplus (4k+1) \oplus (4k+2) \oplus (4k+3) = 0$$
(here, I use $\oplus$ for the bitwise xor operator, which is the more common notation outside programming languages)
For any non-negative integer $n,$ we may find unique non-negative $q,r$ such that $r < 4$ and $n = 4q+r.$  Using the above identity as a guide, we then write the bitwise xor of all the numbers from $0$ to $n$ as
$$\bigoplus_{i=0}^n i = \bigoplus_{k=0}^{q-1}\left((4k)\oplus(4k+1)\oplus(4k+2)\oplus(4k+3)\right) \oplus \bigoplus_{k=0}^{r-1}(4q+k) \oplus n = \bigoplus_{k=0}^{r-1}(4q+k) \oplus n$$
which implies
$$n = \bigoplus_{i=0}^n i \iff \bigoplus_{k=0}^{r-1} (4q+k) = 0$$
From here, we can see that this is true if and only if either $r=1,q=0$ or $r=0.$ In terms of $n,$ this becomes
$$n = \bigoplus_{i=0}^n i \iff n=1 \text{ or } n \text{ is a multiple of } 4$$
Going back to your observation, $n=10$ is the only one that is neither equal to $1$ nor a multiple of $4.$
