All tasks
Easymath

Sum from 1 to n

Time limit 2 s · Memory 64 MBAcceptance: —Solved by: 0

Statement

You are given an integer n. Print the sum 1 + 2 + … + n.

Examples

Example 1
Input
5
Output
15
Example 2
Input
1
Output
1

Constraints

  • 1 ≤ n ≤ 10^9
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.