📜  javascript 阶乘堆栈 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:12.081000             🧑  作者: Mango

代码示例1
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;
}