#CCBCHMOT0000004. Tổng đến ngưỡng cố định (Accumulated Sum up to N)
Tổng đến ngưỡng cố định (Accumulated Sum up to N)
Accumulated Sum up to N
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given a nonnegative integer n, compute 1+2+...+n. For n=0, the sum is zero.
Input
One integer n.
Output
Print the sum of integers from 1 through n.
Subtasks
- Subtask 1 (20%): 0 <= n <= 10.
- Subtask 2 (30%): 0 <= n <= 1000.
- Subtask 3 (50%): 0 <= n <= 100000.
Examples
Example 1
Input
3
Output
6
Explanation
Start at zero and add 1, 2, and 3 to obtain 6.
Example 2
Input
0
Output
0
Explanation
The loop does not run, leaving the sum at zero.