📜  javascript代码示例中的while循环阶乘函数

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

代码示例1
function myfact(number) {
   var fact = 1;
    var i = 1;
    while (i <= number) {
        fact = fact * i;
        i++;
    }
    return fact;
}
console.log(myfact(6));
//Output: 720