Home >>Python Programs >Python Program to Find the Sum of Natural Numbers
In this example, we will see a Python program to find the sum of the given input natural numbers. Natural number is the number that occurs commonly. It is a whole, non-negative number.
Example :
num = int(input("Enter a number: "))
if num < 0:
print("Enter a positive number")
else:
sum = 0
# use while loop to iterate un till zero
while(num > 0):
sum += num
num -= 1
print("The sum is",sum)