(* * $Id: ackermann.ocaml,v 1.9 2001/01/08 02:56:48 doug Exp $ * http://www.bagley.org/~doug/shootout/ * with help from Markus Mottl *) let rec ack m n = if m = 0 then n + 1 else if n = 0 then ack (m - 1) 1 else ack (m - 1) (ack m (n - 1)) let _ = let arg = try int_of_string Sys.argv.(1) with Invalid_argument _ -> 1 in Printf.printf "Ack(3,%d): %d\n" arg (ack 3 arg)