Header Ads

Python - WAP to Print the Sum of 'N' Natural Numbers in Python - 19

This is a Python Code to Print the Sum of 'n' Natural Number's in Python.

Source Code:
num = int(input("\n Enter a Number : "))
temp = num

sum = 0

while (num > 0):
    sum += num
    num -= 1

print(" The sum of '%d' is '%d'." % (temp, sum))

Program Output:

 


.....

No comments