How to find the factorial of a number using javascript?

 Solution: 

FlowChart


Example:

function factorial(n){

if(n === 0){

return 1;}

else{

return n*factorial(n-1);

}

}

testinputs:1) console.log(factorial(6))

2) console.log(factorial(7))

outputs:1) 720, 2) 5040


Post a Comment

0 Comments

Close Menu