%%% -*- mode: erlang -*- %%% $Id: ackermann.erlang,v 1.6 2000/10/07 08:41:43 doug Exp $ %%% http://www.bagley.org/~doug/shootout/ -module(ackermann). -export([main/1]). main() -> main(['1']). main([Arg]) -> Num = list_to_integer(atom_to_list(Arg)), io:fwrite("Ack(3,~w): ~w\n", [Num, ack(3, Num)]), halt(0). ack(0, N) -> N+1; ack(M, 0) -> ack(M-1, 1); ack(M, N) -> ack(M-1, ack(M, N-1)).