Count odd and even Binomial Coefficients of N | Function to count set bits in binary representation of number N ; Count set bits in N ; Return the final count ; Driver Code ; Print odd Binomial coefficients ; Print even Binomial coefficients
function countSetBits ( N ) { let count = 0 ; while ( N != 0 ) { N = N & ( N - 1 ) ; count ++ ; } return count ; } let N = 4 ; let bits = countSetBits ( N ) ; document . write ( " " + " " + ( Math . pow ( 2 , bits ) ) + " " ) ; document . write ( " " + " " + ( N + 1 - ( Math . pow ( 2 , bits ) ) ) ) ;