Count of numbers whose 0 th and Nth bits are set | C ++ implementation of the approach ; Function to return the count of n - bit numbers whose 0 th and nth bits are set ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countNum ( int n ) { if ( n == 1 ) return 1 ; int count = pow ( 2 , n - 2 ) ; return count ; } int main ( ) { int n = 3 ; cout << countNum ( n ) ; return 0 ; }