My task is to calculate number of 1-bits of interval [1,10^16]. Loop is obviously unusable for this case, and I've heard there exists an algorithm for this. Can anyone help?
More generally, an algorithm for number of 1-bits in an interval [1,n] would be nice.
If that helps, I figured that number of 1-bits of interval [1,2^n-1], n positive integer, is n*2^(n-1).