Skip to content

Commit 4d46031

Browse files
committed
fix| factorial solution now passes
1 parent 670d85e commit 4d46031

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

13_factorial/solution/factorial-solution.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const factorial = function(n) {
2-
if (/[.-]/.match(n + '')) return;
3-
if (n === 0 || n === 1) return 1;
4-
return factorial(n - 1) + factorial(n - 2);
2+
if (/[-.]/.test(n + '')) return;
3+
if (+n === 0 || +n === 1) return 1;
4+
return n * factorial(n - 1);
55
};
66

77
// Do not edit below this line

0 commit comments

Comments
 (0)