Count of numbers whose 0 th and Nth bits are set | Java implementation of the approach ; Function to return the count of n - bit numbers whose 0 th and nth bits are set ; Driver code
import java . io . * ; class GFG { static int countNum ( int n ) { if ( n == 1 ) return 1 ; int count = ( int ) Math . pow ( 2 , n - 2 ) ; return count ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( countNum ( n ) ) ; } }