Python program to print sum of n natural numbers

Updated: May 23, 2021


Program:

a=int(input("Enter a number: "))

sum = 0

while(a > 0):

sum=sum+a

a=a-1

print("The sum of natural numbers is",sum)

Output:

Enter a number: 5

The sum of natural numbers is 15

Python program to print sum of n natural numbers video:





83 views0 comments

Recent Posts

See All