PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SCKTCUOIKI0007. Tính tổng từ 1 đến n (Sum from 1 to N)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Đang đọc
Tính tổng từ 1 đến n (Sum from 1 to N)
Sum from 1 to N
**Version: Phuoc Hung OJ Extended
Problem Statement
Given a positive integer , compute . In this exercise, use a loop to accumulate the sum of all integers from through .
Input
The only line contains the integer .
Output
Print exactly one integer equal to .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
5
Output
15
Explanation
For , accumulate the values: , , , , and . Therefore print 15.
Liên quan
Trong các cuộc thi sau: