# Python 3 Program to Find the Sum of Natural Numbers

0
574

Here, I will share a simple Python 3 program to find the sum of natural numbers. Before moving ahead, you should find understand the basic concepts of Python programming language such as variables, data types, and if-else loop statements. If you are looking for a good book to use in your Python learning, then here is our recommended list for beginners.

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

In this Python program, we will first take an input to store the number of terms till which we have to calculate the sum. Next, we will check if the user input is positive or negative. If the input is negative, then the user will see the message “Enter positive number of terms” and if the input is positive, Python will start executing the while loop. \

The while loop calculates the sum of terms until the term is less than zero. After all the iterations of while loop is complete,

```terms = int(input("Enter the number of terms till which you want to find the sum: "))
n = terms
if terms < 0:
print("Enter positive numbers of terms")
else:
sum = 0
while (terms > 0):
sum = sum + terms
terms = terms - 1

print("Sum of", n, "terms =", sum)```

Try it yourself:

### Output

Enter the number of terms till which you want to find the sum: 98989

Sum of 98989 terms = 4899460555 