Write a program that calculates the sum of first 100 natural numbers
and print their sum
Answers
Answered by
0
IAM WRITING THIS IN PYTHON
CODE :
n=int(input("Enter a number: "))
sum1 = 0
sum1 = 0while (n > 0):
sum1 = 0while (n > 0): sum1=sum1+n
sum1 = 0while (n > 0): sum1=sum1+n n=n-1
sum1 = 0while (n > 0): sum1=sum1+n n=n-1print("The sum of first n natural numbers is",sum1)
OUTPUT :
(when you run it it asks "Enter a number: " if you enter 100 then it replies "The sum of first n natural numbers is 5050" you can enter any number.
Similar questions
Chemistry,
3 months ago
Math,
3 months ago
Social Sciences,
6 months ago
Math,
6 months ago
Hindi,
10 months ago