-- -*- mode: eiffel -*-
-- $Id: ackermann.se,v 1.1 2000/10/12 07:11:42 doug Exp $
-- http://www.bagley.org/~doug/shootout/

class ACKERMANN

creation make

feature

   make is

      local
     num: INTEGER;
      do
     if argument_count = 1 then
        num := argument(1).to_integer
     else
        num := 1
     end
         std_output.put_string("Ack(3,")
         std_output.put_integer(num)
         std_output.put_string("): ")
         std_output.put_integer(ack(3, num))
         std_output.put_new_line
      end;

feature {NONE}

   ack(m, n:INTEGER):INTEGER is
      do
     if m = 0 then
        Result := n + 1
     elseif n = 0 then
        Result := ack(m - 1, 1)
     else
        Result := ack(m - 1, ack(m, (n - 1)))
     end
      end;
end