Skip to content

Commit 718cce5

Browse files
committed
Make sure factorial is defined in intro
1 parent c153248 commit 718cce5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

code/intro.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ function sum(array) {
1818
total += array[i];
1919
return total;
2020
}
21+
22+
function factorial(n) {
23+
if (n == 0) {
24+
return 1;
25+
} else {
26+
return factorial(n - 1) * n;
27+
}
28+
}

0 commit comments

Comments
 (0)