Computer Science, asked by kshatrishreyap04, 10 months ago

program to print the
Sum of natural no​

Answers

Answered by Anonymous
1
Hi Mate,

Here is a code to print the sum of natural number/s in Python,
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)

[Apply indications at your own]

Good Day...!!
Similar questions