# -*- mode: icon -*-
# $Id: ackermann.icon,v 1.2 2000/12/17 23:34:17 doug Exp $
# http://www.bagley.org/~doug/shootout/

procedure main(argv)
    num := argv[1];
    write("Ack(3,", num, "): ", ack(3,num));
end

procedure ack(m,n)
    if (m == 0) then {
    return(n + 1)
    }
    if (n == 0) then {
    return(ack(m-1, 1))
    }
    return(ack(m-1, ack(m, n-1)))
end