Learning User Input with Natural Numbers @ Dcoder

Words
45
Reading
1 min
3y
Listen to this post
~1 min

Problem: The numbers 1,2,3.. are known as Natural numbers. Calculate the sum of all the natural numbers from 1 to N, where N will be the input.
Input: A positive integer N
Output: Output will be sum of numbers from 1 to N
Constraints: 1<N<1000
Sample Input: 5
Sample Output:
15

print(sum(range(1, int(input())+1)))
Learning User Input with Natural Numbers @ Dcoder | Ecency