Skip to content

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.

number

input, must be an integer number 1 or greater

number

factorial: n!

if n is less than 0 or not an integer

factorial(5); // => 120