Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/rekursiya-1-dan-n-gacha-yigindi

Sum from 1 to N

Easy 1000 ms 64 MB 22%
Share

You are given a positive integer $n$. Using a recursive function, compute the sum of all integers from $1$ to $n$:

$$S(n) = \begin{cases} 1, & n = 1 \\ n + S(n - 1), & n > 1 \end{cases}$$

Bars from 1 to n: the last bar is n, the rest are the previous sum

Input

One line with one integer $n$ ($1 \le n \le 1000$).

Output

The sum of the numbers from $1$ to $n$.

Note

$1 \le n \le 1000$

Examples

Input #1
1
Output #1
1
Input #2
5
Output #2
15

Sign in to submit a solution

Signing up is free and takes a minute.