Count of binary strings of given length consisting of at least one 1 | Java program to implement the above approach ; Function to return the count of Strings ; Calculate Math . pow ( 2 , n ) ; Return Math . pow ( 2 , n ) - 1 ; Driver Code
import java . util . * ; class GFG { static long count_Strings ( long n ) { int x = 1 ; for ( int i = 1 ; i < n ; i ++ ) { x = ( 1 << x ) ; } return x - 1 ; } public static void main ( String [ ] args ) { long n = 3 ; System . out . print ( count_Strings ( n ) ) ; } }