Menu Close

Sum of Natural Numbers.

Python Program to Find the Sum of First N Natural Numbers

Input:
Value of “N”

Output:
Print the Sum of N natural Numbers

N=int(input('Enter the N value: '))
sum1=0
for i in range(N+1):
  sum1+=i
print('Sum of N natural numbers: ',sum1) #sum of n natural numbers

Input_1:
Enter the N value: 200
Output:
Sum of N natural numbers: 20100


Input_2:
Enter the N value: 18
Output:
Sum of N natural numbers: 171


Input_3:
Enter the N value: 167
Output:
Sum of N natural numbers: 14028


Input_4:
Enter the N value: 100
Output:
Sum of N natural numbers: 5050


Morae Q!