Scientific Calculator

(public) silentmatt/ackermann

By silentmatt Matthew Crumley

The Ackermann Function. Be careful.

Tagged: recursion

var Ackermann = function(m, n) {
    m == 0 ?
        n + 1
    : m > 0 and n == 0 ?
        Ackermann(m - 1, 1)
    : m > 0 and n > 0 ?
        Ackermann(m - 1, Ackermann(m, n - 1))
    :
        error()
};

spam? | offensive?

0 Comments

Sign in to leave a comment