Count trailing zeroes present in binary representation of a given number using XOR | C # implementation of the above approach ; Function to print count of trailing zeroes present in binary representation of N ; Stores XOR of N and ( N - 1 ) ; Return count of set bits in res ; Driver Code ; Function call to print the count of trailing zeroes in the binary representation of N
using System ; public class GFG { public static int countTrailingZeroes ( int N ) { int res = ( int ) Math . Log ( N ^ ( N - 1 ) , 2.0 ) ; if ( res >= 0 ) return res ; else return 0 ; } static public void Main ( ) { int N = 12 ; Console . WriteLine ( countTrailingZeroes ( N ) ) ; } }