## Write a Node Js program to print the Factorial of a number
function factorial(n) {
if (n === 0 || n === 1) {
return
1;
}
else {
return n *
factorial(n - 1);
}
}
const number = 10;
// Change this to calculate the factorial of a different number
const result = factorial(number); // Function
calling
console.log(`Factorial of ${number} is: ${result}`);
|
No comments:
Post a Comment