diff --git a/calculator/calculator.js b/calculator/calculator.js index be09295..8ad98c0 100644 --- a/calculator/calculator.js +++ b/calculator/calculator.js @@ -19,12 +19,10 @@ function power(a, b) { } function factorial(n) { - if (n == 0) return 0; - let product = 1; - for (let i = n; i > 0; i--) { - product *= i; - } - return product; + if (n===0){ + return 1; +} + return n * factorial (n-1); } module.exports = {