Value required to be added to N to obtain the sum of first M multiples of K | Function to print the value to be added to N to obtain sum of first M multiples of K ; Store the sum of the first M multiples of K ; Store the value to be added to obtain N ; Input
function printNumber ( N , K , M ) { var sum = K * ( ( M * ( M + 1 ) ) / 2 ) ; return sum - N ; } var N = 17 ; var K = 3 ; var M = 4 ; document . write ( printNumber ( N , K , M ) ) ;