text: Count odd and even Binomial Coefficients of N | C # program for the above approach ; 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
code: using System ; class GFG { static int countSetBits ( int N ) { int count = 0 ; while ( N != 0 ) { N = N & ( N - 1 ) ; count ++ ; } return count ; } public static void Main ( ) { int N = 4 ; int bits = countSetBits ( N ) ; Console . WriteLine ( " Odd ▁ " + " : ▁ " + ( int ) ( Math . Pow ( 2 , bits ) ) ) ; Console . WriteLine ( " Even ▁ " + " : ▁ " + ( N + 1 - ( int ) ( Math . Pow ( 2 , bits ) ) ) ) ; } }