Given integer n, find n!.
Example
For n = 5, the output should befactorial(n) = 120.
Here 1 * 2 * 3 * 4 * 5 = 120.
Input/Output
- [time limit] 4000ms (js)
-
[input] integer n
Constraints:
0 ≤ n ≤ 10. -
[output] integer
Solution
_ = factorial = n =>
n ? n * _(n - 1) : 1