Given a non-negative integer n, return its factorial (n!).
The factorial of n is the product of all positive integers less than or equal to n. By definition, 0! = 1.
For example, factorial(5) returns 120 because 5 × 4 × 3 × 2 × 1 = 120.
n = 5120n = 01n = 110 <= n <= 20The result fits in a 64-bit integer.Run your code to see results
Use Cmd+Enter to run