Fix formula (#206)
The current version of the formula incorrectly handles the factorial(0) and causes an infinite loop
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user