Re:Counting set bits in an interesting way
by goldenkey on Saturday April 30, 2022 @08:22AM
(#31215489)
Nice analysis, it's basically just an alternating series that uses the inclusion exclusion principle.
https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_pr...
So this bit of x, if set, contributes (1<<i) - (1<<(i-1) + 1<<(i-2) + ... + 1<<0) = 1 to diff altogether.