Write a Python Program to Find the Sum of Natural Numbers

Python Program to Find the Sum of Natural Numbers

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn  Python programming concepts. You can learn Python language at your own speed and time. One can learn concepts of Python language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

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

Write a Python Program to Find the Sum of Natural Numbers

PROGRAM: Python Program to Find the Sum of Natural Numbers

/* Python Program to Find the Sum of Natural Numbers */

# Sum of natural numbers up to num

num = 16

if num < 0:
print(“Enter a positive number”)
else:
sum = 0
# use while loop to iterate until zero
while(num > 0):
sum += num
num -= 1
print(“The sum is”, sum)

OUTPUT :-

The sum is 136

Leave a Reply

Your email address will not be published. Required fields are marked *