Skip to content

Commit cd38dc1

Browse files
authored
Fix formula (egonSchiele#206)
The current version of the formula incorrectly handles the factorial(0) and causes an infinite loop
1 parent 38f962f commit cd38dc1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

03_recursion/ES6/03_factorial.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @returns {number} Result
55
*/
66
const fact = x => {
7-
if (x === 1) return 1;
7+
if (x === 0) return 1;
88
return x * fact(x - 1);
99
};
1010

0 commit comments

Comments
 (0)