// 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 a program to find Reverse a String using node js |
How to implement a Stack using node js |
Check if a String is a Palindrome using node js |
Find the Maximum Number in an Array |
How to check if two strings are anagrams |
How to to check if a number is a palindrome using node js |
How to implement a Queue |
Find the longest word in a sentence using node js |