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

~/algor $ cat problems/rekursiya-faktorial

Factorial

Easy 1000 ms 64 MB 23%
Share

You are given a non-negative integer $n$. Using a recursive function, compute $n!$ (n factorial):

$$0! = 1$$
$$n! = n \times (n - 1)! \quad (n \ge 1)$$

The calls go down from n to 0, at 0 the answer is 1, and the result goes back up

Input

One line with one integer $n$ ($0 \le n \le 12$).

Output

The value of $n!$.

Note

$0 \le n \le 12$. The result fits in a standard 32-bit integer.

Examples

Input #1
0
Output #1
1
Input #2
5
Output #2
120

Sign in to submit a solution

Signing up is free and takes a minute.