Fix formula (#206)

The current version of the formula incorrectly handles the factorial(0) and causes an infinite loop
This commit is contained in:
spring monkey
2022-11-19 01:29:39 +04:00
committed by GitHub
parent 38f962f2a3
commit cd38dc146d

View File

@@ -4,7 +4,7 @@
* @returns {number} Result
*/
const fact = x => {
if (x === 1) return 1;
if (x === 0) return 1;
return x * fact(x - 1);
};