Faktorial Rekursion JavaScript
function factorial(n){
if(n<=1){
return 1;
}else{
var result = 1;
result = factorial(n-1) * n;
}
return result;
}
tinydev
function factorial(n){
if(n<=1){
return 1;
}else{
var result = 1;
result = factorial(n-1) * n;
}
return result;
}
function factorialRecursion(n) {
if (n == 1) {
return 1;
}
return n * factorialRecursion(n - 1);
}
console.log(factorialRecursion(5))
//Output: 120