Sum of xor of digits of all numbers from 1 to N when N is very large
<p>Given 1 and N , we need to find the sum of XOR values of digits of all numbers from 1 to N,
For example  for N  ,  we need to compute function F</p>

<pre><code>F(k){
    ans =0;
    while(k&gt;0){
      ans= ans^(k%10);
      k/=10;
   }
   return ans;
}
</code></pre>

<p>for  K in [1,N].</p>

<p>is there a efficient way to do say .
As far as i can think we should count the no of times a value V will resultant XOR using DP , but i cant think of way to implement it.</p>

<p>Please Give some Idea upon it. </p>

<p>Example : F (37) = 3 ^ 7 = 4</p>

<p>Note : N can be as large as 10^18</p>