Number of compositions of a natural number | Python code to find the total number of compositions of a natural number ; function to return the total number of composition of n ; Driver Code
def countCompositions ( n ) : NEW_LINE INDENT return ( 2 ** ( n - 1 ) ) NEW_LINE DEDENT print ( countCompositions ( 4 ) ) NEW_LINE