A Sum Problem
This is a sample problem to demonstrate the runtimes of different solutions with different time complexities.
Calculate the sum of integers in the range \([1, N]\).
Input Specification
The first line of the input will contain an integer \(N\) \((1 \le N \le 10^9)\).
Output Specification
Output the sum of integers in the range \([1, N]\). For C++ and Java users make sure you use long long
or long
to prevent integer overflow.
Sample Input
4
Sample Output
10
Sample Explanation
The sum is \(1 + 2 + 3 + 4 = 10\).
Comments