8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 35ed3d7 + d63ee47 commit b14ac4eCopy full SHA for b14ac4e
calculator/calculator.js
@@ -19,14 +19,23 @@ function power(a, b) {
19
}
20
21
function factorial(n) {
22
- if (n == 0) return 0;
+ if (n == 0) return 1;
23
let product = 1;
24
for (let i = n; i > 0; i--) {
25
product *= i;
26
27
return product;
28
29
30
+// This is another implementation of Factorial that uses recursion
31
+// THANKS to @ThirtyThreeB!
32
+function recursiveFactorial(n) {
33
+ if (n===0){
34
+ return 1;
35
+ }
36
+ return n * factorial (n-1);
37
+}
38
+
39
module.exports = {
40
add,
41
subtract,
0 commit comments