javascript factorial html code example
Example 1: factorial javascript
// Simple arrow function solution
var factorial = n => (n <= 0) ? 1: n * factorial(n - 1);
Example 2: factorial program in javascript
function fact(N){
if(N <= 1){
return "1";
}
else
{
return N * fact(N-1);
}
}
fact(5);