Count number of bits to be flipped to convert A to B | Function that count set bits ; Function that return count of flipped number ; Return count of set bits in a XOR b ; Driver code
< ? php function countSetBits ( $ n ) { $ count = 0 ; while ( $ n ) { $ count += 1 ; $ n &= ( n - 1 ) ; } return $ count ; } function FlippedCount ( $ a , $ b ) { return countSetBits ( $ a ^ $ b ) ; } $ a = 10 ; $ b = 20 ; echo FlippedCount ( $ a , $ b ) ; ? >