title: parity of set bits after xor of two numbers
body: <p>I found an observation by testing in C++. </p>
  
  <p>Observation is ,</p>
  
  <p>1 ) If two numbers where both numbers have <strong>odd</strong> number of set bits in it then its XOR will have <strong>even</strong> number of set bits in it.</p>
  
  <p>2 ) If two numbers where both numbers have <strong>even</strong> number of set bits in it then its XOR will have <strong>even</strong> number of set bits in it.</p>
  
  <p>1 ) If two numbers where <strong>one number has even number of set bits</strong> and <strong>another has odd number of set bits</strong>  then its XOR will have <strong>odd</strong> number of set bits in it.</p>
  
  <p>I could not prove it. I want to prove it. Please help me.</p>
  
  <p>Code that i executed on my computer is </p>
  
  <pre><code>#include&lt;bits/stdc++.h&gt;
  using namespace std;
  int main(){
      vector&lt;int&gt; vec[4];
      for(int i=1;i&lt;=100;i++){
         for(int j=i+1;j&lt;=100;j++){ 
           int x=__builtin_popcount(i)%2;
           int y=__builtin_popcount(j)%2;
           int in=0;
           in|=(x&lt;&lt;1);
           in|=(y&lt;&lt;0);
           int v=__builtin_popcount(i^j)%2;
           vec[in].push_back(v);
        }
      }
        for(int i=0;i&lt;4;i++){
           for(int j=0;j&lt;vec[i].size();j++) cout&lt;&lt;vec[i][j] &lt;&lt; " ";
           cout &lt;&lt; endl;
        }
     return 0;
  }
  </code></pre>
  
  <p>It gives me </p>
  
  <p>100 zeros in first line
  100 ones in second line
  100 ones in third line
  100 zeros in fourth line</p>
  
  <p>If there is a doubt in understanding the code then please tell me in comments.</p>