Print the sum of 1st N natural numbers.
Posted on | Sunday, 14 May 2023 | No Comments
Given a positive integer N, print the sum of 1st N natural numbers.
Input Format
First and only line of input contains a positive integer - N.
Constraints
1 <= N <= 104
Output Format
Print the sum of 1st N natural numbers.
Sample Input 0
4
Sample Output 0
10
p=int(input())
a=0
while p>0:
a=a+p
p=p-1
print(a)

Category:
Python
Comments
Categories
Archives
- May 2023 (30)
Leave a Reply