Let us first understand difference between the bit patterns of N and N-1 , when N>0
Case(1): N is Even
If N is even then, we can get N-1 by complimenting all the bits from rightmost "1" to least significant bit of N's bit pattern.
Hence, N&(N-1) will have all the bits same as N except the position of N's rightmost "1"
Example- N= 1010111000 , N-1=1010110111
Now, N&(N-1) = 1010110000
Case(2): N is Odd
If N is odd then, we can get N-1 just by complementing least significant bit. Hence, N&(N-1) will have all the bits same as N except the least significant bit(which will be 0)
Example- N= 1010111001 , N-1=1010111000
So, conclusion is , If C(N) denotes the number of 1s in N's bit pattern , then C(N)= C(N&(N-1)) +1