if n is a power of 2. Then those numbers are 2,4,8,16…… and those binary numbers are 0010,0100,1000……. . N-1 means 1,3,7,15… those equivalent binary numbers are 0001,0011,0111…., if you apply AND operation between 1 and 2, 3 and 4, 7 and 8..etc. we will get 0000 only.

n&n-1==0 will return true . if n is a power of 2 . Then those numbers are 2,4,8,16…… and those binary numbers are 0010,0100,1000……. . N-1 means 1,3,7,15… those equivalent binary numbers are 0001,0011,0111…., if you apply AND operation between 1 and 2, 3 and 4, 7 and 8..etc. we will get 0000 only.