Skip to content

Commit cd38dc1

Browse files
authored
Fix formula (#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

Diff for: 03_recursion/ES6/03_factorial.js

+1-1
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)