In mathematics, natural numbers are those numbers that we use to count quantities like 1,2,3,4, etc. These numbers are real, any positive integer is a natural number.

Finding the sum of natural numbers is a common problem in mathematics and programming. In this article, we will learn how to write a Python program to find the sum of natural numbers.

## The Algorithm:

To find the sum of natural numbers, we can use various approaches. Here, we’ll be using a simple mathematical formula: sum = n * (n + 1) / 2

The above formula is derived using the mathematical principle of arithmetic series.

## The Code:

Now, let’s look at the Python program that finds the sum of natural numbers.

```
n = int(input("Enter a positive integer: "))
sum = n * (n + 1) / 2
print("The sum of the first", n, "natural numbers is", sum)
```

### Explanation of the Code:

The program accepts a positive integer (n) from the user as input.

Then, using the formula mentioned above, the program calculates the sum of the first “n” natural numbers.

Finally, the program displays the sum of the first “n” natural numbers.

## FAQs:

### What are Natural Numbers?

Natural numbers are whole numbers greater than 0, which we use to count quantities like 1,2,3,4, etc.

### How to Find the Sum of Natural Numbers?

The sum of natural numbers can be found using the formula: sum = n*(n+1)/2

### Can We Find the Sum of Natural Numbers Using a Loop?

Yes, we can use a loop to find the sum of natural numbers. Here’s an example:

```
n = int(input("Enter a positive integer: "))
sum = 0
for i in range(1, n+1):
sum += i
print("The sum of the first", n, "natural numbers is", sum)
```

### What is the Use of Natural Numbers?

Natural numbers are used in various mathematical and scientific applications, such as counting objects, measuring time, and solving equations.

### Can the Sum of Natural Numbers be a Negative Number?

No, the sum of natural numbers cannot be negative.

Mukul Kandhari is an internet marketer, SEO, and web developer with a passion for programming.