factorial
factorial(
n):number
Defined in: src/factorial.js:13
A Factorial, usually written n!, is the product of all positive integers less than or equal to n. Often factorial is implemented recursively, but this iterative approach is significantly faster and simpler.
Parameters
Section titled “Parameters”number
input, must be an integer number 1 or greater
Returns
Section titled “Returns”number
factorial: n!
Throws
Section titled “Throws”if n is less than 0 or not an integer
Example
Section titled “Example”factorial(5); // => 120