// 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? |
Write program to remove duplicates from an Array |
Write function to implement FizzBuzz using node js |
Find the Maximum Number in an Array |
How to check if two strings are anagrams |
How to implement a linked list using node js |
Write a program to find Reverse a String using node js |
Write a function to check if a number is prime using node js |