The Ackermann function looks "pretty" in JavaScript!

Recursion is fun! I checked out some code for the Ackermann function in many different programming languages and thought " === " and “?” are great to have around when you want them!

Warning integer overflow may occur! :smiley:

function ackermann(m, n) {
 return m === 0 ? n + 1 : ackermann(m - 1, n === 0  ? 1 : ackermann(m, n - 1));
}

:vulcan_salute:

1 Like