Number of ways to obtain each numbers in range [ 1 , b + c ] by adding any two numbers in range [ a , b ] and [ b , c ] | Python3 program to calculate the number of ways ; Initialising the array with zeros . You can do using memset too . ; Printing the array ; Driver code
def CountWays ( a , b , c ) : NEW_LINE INDENT x = b + c + 1 ; NEW_LINE arr = [ 0 ] * x ; NEW_LINE for i in range ( a , b + 1 ) : NEW_LINE INDENT for j in range ( b , c + 1 ) : NEW_LINE INDENT arr [ i + j ] += 1 ; NEW_LINE DEDENT DEDENT for i in range ( 1 , x ) : NEW_LINE INDENT print ( arr [ i ] , end = " ▁ " ) ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = 1 ; NEW_LINE b = 2 ; NEW_LINE c = 2 ; NEW_LINE CountWays ( a , b , c ) ; NEW_LINE DEDENT