Python program to print sum of n natural numbers
- Rajesh Singh
- Nov 11, 2020
- 1 min read
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:
Comments