When you AND a number with its predecessor, the last 1 bit at the right always gets removed.
So, to get the count of 1 bits in a number, I have to AND the number with its predecessor to remove the farthest 1-bit at the right, count that step, then repeat the same process with the resulting number till I get to zero.
- Time complexity: O(log n)