Calculates the factorial of a non-negative integer n.
n
The factorial of a number n is the product of all positive integers less than or equal to n.
A non-negative integer.
The factorial of n.
Will throw an error if n is negative or not an integer.
factorial(0); // returns 1factorial(5); // returns 120factorial(3); // returns 6 Copy
factorial(0); // returns 1factorial(5); // returns 120factorial(3); // returns 6
Calculates the factorial of a non-negative integer
n
.The factorial of a number
n
is the product of all positive integers less than or equal ton
.