// 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 longest word in a sentence using node js |
Write function to implement FizzBuzz using node js |
Write program to remove duplicates from an Array |
Write a program to find Reverse a String using node js |
How to implement a Queue |
Write a function to check if a number is prime using node js |
How to implement a simple calculator using node js |