Given only n, we have to find sum(i|j) over all i,j in range.(0,n)
i have tried to split it into ranges of power of 2 but not getting proper insight of how to solve
i used O(n^2) code:
int s=0;
for(int i=1;i<=n;i++)
{for(int j=1;j<=n;j++)s+=(i|j);}
i get expected output but i need optimum solution.