Number of compositions of a natural number | Java program to find the total number of compositions of a natural number ; Return 2 raised to power ( n - 1 ) ; Driver Code
import java . io . * ; import java . util . * ; class GFG { public static int countCompositions ( int n ) { return 1 << ( n - 1 ) ; } public static void main ( String args [ ] ) { int n = 4 ; System . out . print ( countCompositions ( n ) ) ; } }