tests/ruby/common/src/ackermann.ruby

#!/usr/local/bin/ruby
# -*- mode: ruby -*-
# $Id: ackermann.ruby,v 1.2 2003/12/30 01:25:05 davidw Exp $
# http://www.bagley.org/~doug/shootout/

# END COMMENT
def ack(m, n)
    if m == 0 then
	n + 1
    elsif n == 0 then
	ack(m - 1, 1)
    else
	ack(m - 1, ack(m, n - 1))
    end
end

NUM = Integer(ARGV.shift || 1)
print "Ack(3,", NUM, "): ", ack(3, NUM), "\n"

Generated by GNU enscript 1.6.3.