programming-examples/js/Recursion/Write a JavaScript program to calculate the factorial of a number..js

11 lines
161 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function factorial(x)
{
if (x === 0)
{
return 1;
}
return x * factorial(x-1);
}
console.log(factorial(5));