11 lines
161 B
JavaScript
11 lines
161 B
JavaScript
|
function factorial(x)
|
||
|
{
|
||
|
|
||
|
if (x === 0)
|
||
|
{
|
||
|
return 1;
|
||
|
}
|
||
|
return x * factorial(x-1);
|
||
|
|
||
|
}
|
||
|
console.log(factorial(5));
|