diff --git a/Algorithms/Ackermann/Ackermann.js b/Algorithms/Ackermann/Ackermann.js index 3597bbbe3..dae8273d4 100644 --- a/Algorithms/Ackermann/Ackermann.js +++ b/Algorithms/Ackermann/Ackermann.js @@ -1,10 +1,10 @@ -n = 2; -m = 3; + let n = 2; +let m = 3; function ackermann(n, m) { - if (n == 0) return m + 1; - if (m == 0) return ackermann(n - 1, 1); + if (n === 0) return m + 1; + if (n > 0 && m === 0) return ackermann(n - 1, 1); return ackermann(n - 1, ackermann(n, m - 1)); } -console.log(`ackermann(${n},${m}) = `, ack(n, m)); +console.log(`ackermann(${n}, ${m}) = `, ackermann(n, m));