javascript factorial stack code example
Example: javascript factorial stack
function factorial(n) {
let s = new Stack();
while (n>1){
s.push(n--);
}
let product = 1;
while (s.length() > 0) {
product *= s.pop();
}
return product;
}