Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it

11 Feb 2024

NODE JS PROGRAM - FACTORIAL OF A NUMBER


 ## 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