factorial of a number

前端 未结 28 2433
滥情空心
滥情空心 2020-12-09 11:57

I have the following code but it is not giving perfect result for factorial can u find it out plz



        
28条回答
  •  一向
    一向 (楼主)
    2020-12-09 12:41

    //This is fastest way to implement factorial
    const fact = n => !n ? 1 : n * fact(--n);
    
    console.log(fact(10))

提交回复
热议问题