// 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
what is CI/CD: Github Actions? |
How to implement a Stack using node js |
Check if a String is a Palindrome using node js |
How to convert Celsius to Fahrenheit using node js |
Write to function to calculate the factorial of a number |
Write function to implement FizzBuzz using node js |
How to implement a simple calculator using node js |
Find the Average of an Array using node js |