// 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 |
How to implement a simple calculator using node js |
Find the longest word in a sentence using node js |
Write a function to capitalize the first letter of each word in a sentence using node js |
How to check if two strings are anagrams |
Write a program to find Reverse a String using node js |
How to convert Celsius to Fahrenheit using node js |
Find the intersection of two arrays using node js |