Sum of multiples of a number up to N | Calculates sum of multiples of a number upto N ; Number of multiples ; sum of first m natural numbers ; sum of multiples ; Driver Code
def calculate_sum ( a , N ) : NEW_LINE INDENT m = N / a NEW_LINE sum = m * ( m + 1 ) / 2 NEW_LINE ans = a * sum NEW_LINE print ( " Sum ▁ of ▁ multiples ▁ of ▁ " , a , " ▁ up ▁ to ▁ " , N , " ▁ = ▁ " , ans ) NEW_LINE DEDENT calculate_sum ( 7 , 49 ) NEW_LINE