Computer Science, asked by Anonymous, 7 months ago

PYTHON CHALLENGE#2
WRITE A PROGRAM TO PRINT THE SUM OF FIRST N NATURAL NUMBERS

PLEASE DO IT YOURSELF
DON'T USE GOOGLE

YESTERDAY CHALLENGE WINNER: shivangiryan

Go and CRACK IT###########




Answers

Answered by HERO1234567
2

Answer:

The sum is 136.

Explanation:

# Sum of natural numbers up to num

num = 16

if num < 0:

print("Enter a positive number")

else:

sum = 0

# use while loop to iterate until zero

while(num > 0):

sum += num

num -= 1

print("The sum is", sum)

Mark as brainlist.

Answered by Anonymous
3

Answer:

'''YESTERDAY CHALLENGE WINNER: shivangiryan

Go and CRACK IT###########'''

thank you... :)

Explanation:

n=int(input("enter the limit"))

sum=0

for i in range(1,n+1):

   sum+=i

print(sum,"is the sum of first ",n,"natural numbers")

Similar questions