Count trailing zeroes present in binary representation of a given number using XOR | Function to print count of trailing zeroes present in binary representation of N ; Count set bits in ( N ^ ( N - 1 ) ) ; If res < 0 , return 0 ; Driver Code ; Function call to print the count of trailing zeroes in the binary representation of N
function countTrailingZeroes ( N ) { let res = parseInt ( Math . log ( N ^ ( N - 1 ) ) / Math . log ( 2 ) ) ; return res >= 0 ? res : 0 ; } let N = 12 ; document . write ( countTrailingZeroes ( N ) ) ;