# DS051023 (Loops practice exercise)

Write a program to get sum of first n natural numbers using loop and take the value of n from user input.

‘’’

Input : n = 10

n natural numbers : 1,2,3,4,5,6,7,8,9,10

sum : 1+2+3+4+5+6+7+8+9+10 = 55

Output : 55

‘’’

n = int(input(“Enter the number”))

sum = 0

for i in range(n+1):
sum+=i

print(f"sum of first {n} natural number is {sum}")

1 Like