// 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
How to implement a Queue |
Find the intersection of two arrays using node js |
Find the Average of an Array using node js |
Find the Maximum Number in an Array |
How to to check if a number is a palindrome using node js |
How to implement a simple calculator using node js |
Write a function to check if a number is prime using node js |
what is CI/CD: Github Actions? |