title: Direct formula for summing XOR
body: <p>I have to XOR numbers from 1 to N, does there exist a direct formula for it ?</p>
  
  <p>For example if  <code>N = 6</code> then <code>1^2^3^4^5^6 = 7</code> I want to do it without using any loop so I need an O(1) formula (if any)</p>