Recursion
Recursion-02
Recursion-03
Recursion-04
~/algor $ cat problems/rekursiya-1-dan-n-gacha-yigindi
Sum from 1 to N
Easy
1000 ms
64 MB
22%
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}$$
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