Sum of multiples of a number up to N | Function for calculating sum of multiples of a upto N ; Number of multiples ; Sum of first m natural numbers ; Sum of multiples ; Driver code
function calculate_sum ( a , N ) { m = N / a ; sum = m * ( m + 1 ) / 2 ; ans = a * sum ; return ans ; } let a = 7 ; let N = 49 ; document . write ( " " + a + " " + N + " " + calculate_sum ( a , N ) ) ;