# Python Program to Find the Sum of Natural Numbers

By | October 3, 2021

Here in this article, we have provided a python program that can find the sum of n natural numbers using Python loop.

## Prerequisite topics to create this Program

• Python Input, Output
• Python if…else statement
• Python Data types
• Python Operators
• Python Loop

#### Steps

• First, we ask the user to enter a number n.
• Using the int() function we will convert the entered string into an integer value.
• Now using the for loop we will go through the range 1 to the number n+1, add all the numbers and print sum as an output.

#### Python Program to Find the Sum of Natural Numbers:

Code:

```n = int(input("Enter the number:" ))
sum=0
if n > 1:
for i in range(1,n+1):
sum+=i
print("The sum of all natural number upto",n,"is ",sum)
else:
print("Please Enter a value greater than 1")```

Output 1:

```Enter the number:2
The sum of all natural numbers upto 2 is 3```

Output2:

```Enter the number:20
The sum of all natural numbers upto 20 is 210```