javascript factorial word code example
Example 1: javascript factorial
function factorial(n) {
if (n < 0) return;
if (n < 2) return 1;
return n * factorial(n - 1);
}
Example 2: javascript factorial with closure
function calcularFatorial(num) {
return num > 1 ? num * calcularFatorial(num - 1) : 1;
}