// Factorial of Number in Javascript using Recursive call in javascript
function factorial(number){
if(number === 0){
return 1;
}
return number * factorial( number -1);
}
console.log(factorial(4));
// how to find factorial of a number using Recursion in javascript
function factorial(n) {
if(n<=1){
return 1;
}else{
return n * factorial(n - 1);
}
}
console.log(factorial(5));
// output : 120
function factorial(num){
if(num < 2) return 1;
return factorial(num-1) * num;
}
console.log(factorial(5)); //120
function factorialRecursion(n) {
if (n == 1) {
return 1;
}
return n * factorialRecursion(n - 1);
}
console.log(factorialRecursion(5))
//Output: 120
System.out.println(val)