#121Easy
Factorial
Time: 1 s · Memory: 256 MB
- Recursion
Statement
, . Compute with a recursive function: is the base case, moves to a smaller problem.
Input format
A single integer ().
Output format
A single integer — .
Examples
Input
5
Output
120
Input
0
Output
1
Note
A recursive function has two parts: the base case (returns an answer without calling itself) and the recursive step (calls itself with a smaller argument). Without a base case the function calls itself forever.
does not fit in int — use a 64-bit type (long long, int64).
