// Function to calculate the factorial of a number
function factorial(n) {
if (n === 0 || n === 1) {
return 1;
}
return n * factorial(n - 1);
}
// Example usage
const result = factorial(5);
console.log(result);
// Function to calculate the factorial of a number
function factorial(n) {
if (n === 0 || n === 1) {
return 1;
}
return n * factorial(n - 1);
}
// Example usage
const result = factorial(5);
console.log(result);
Related
Write to function to calculate the factorial of a number |
Find the Average of an Array using node js |
Write program to remove duplicates from an Array |
How to implement a Stack using node js |
How to to check if a number is a palindrome using node js |
Find the Maximum Number in an Array |
Write a function to capitalize the first letter of each word in a sentence using node js |
Find the intersection of two arrays using node js |