write an algorithm to find the sum of natural numbers from 1 to 300 numbers.
Answers
Answered by
2
Answer:
run in python
Explanation:
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)
Similar questions