Learning User Input with Natural Numbers @ Dcoder

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)))
H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center