Count of non decreasing arrays of length N formed with values in range L to R | Function to return the count of different arrays ; No such combination exists ; Arrays formed with single elements ; Driver code
def countSum ( N , L , R ) : NEW_LINE INDENT if ( L > R ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT if ( N == 1 ) : NEW_LINE INDENT return R - L + 1 ; NEW_LINE DEDENT if ( N > 1 ) : NEW_LINE INDENT return ( N - 2 ) * ( R - L ) + 1 ; NEW_LINE DEDENT return 0 ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N , L , R = 4 , 4 , 6 ; NEW_LINE print ( countSum ( N , L , R ) ) ; NEW_LINE DEDENT