Computer Science, asked by sahusushreepriyadars, 1 month ago

Write a javascript program to find sum of number from N to M, Where value of M, N are entered by the user​

Answers

Answered by priyanshuawas011
1

Answer:

/ program to display the sum of natural numbers

// take input from the user

const number = parseInt(prompt('Enter a positive integer: '));

let sum = 0;

// looping from i = 1 to number

// in each iteration, i is increased by 1

for (let i = 1; i <= number; i++) {

sum += i;

}

console.log('The sum of natural numbers:', sum);

Answered by armaanshaikh98346813
1

Answer:

function numberSum(N) {

var total = 0;

for(var i = 1; i <= N; i++){

total += i;

}

return total;

}

Explanation:

mark me as brainliest

please

Similar questions
Math, 9 months ago