Computer Science, asked by aryankamble527, 1 month ago

Write an event driven JavaScript program to display addition of first 1 0 natural numbers.​

Answers

Answered by Angeldiya85
10

Answer:

let s = 0;

for (i = 1; i <= 10; i++) {

s = s + i;

}

console.log("Sum of first 10 natural numbers:" + s);

Explanation:

Natural numbers begin at 1 and increment to infinity: 1, 2, 3, 4, 5, etc. Therefore, the first ten natural numbers are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. And the mean of three numbers a, b, c is a + b + c3. Hence, the mean of the first 10 natural numbers is 5.5. Sum of first 10 natural numbers:55

Answered by Itzpureindian
0

JavaScript Program to Find the Sum of Natural Numbers

In this example, you will learn to write a program that finds the sum of natural numbers in JavaScript.

To understand this example, you should have the knowledge of the following JavaScript programming topics:

JavaScript for loop

JavaScript while and do...while Loop

The positive integers 1, 2, 3, ... are known as natural numbers.

Example 1: Sum of Natural Numbers Using for Loop

Similar questions