Count of possible subarrays and subsequences using given length of Array | Function to count the subarray for the given array ; Function to count the subsequence for the given array length ; Driver Code
def countSubarray ( n ) : NEW_LINE INDENT return ( ( n ) * ( n + 1 ) ) // 2 NEW_LINE DEDENT def countSubsequence ( n ) : NEW_LINE INDENT return ( 2 ** n ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 5 NEW_LINE print ( countSubarray ( n ) ) NEW_LINE print ( countSubsequence ( n ) ) NEW_LINE DEDENT