tests/python/common/src/ackermann.python

#!/usr/local/bin/python
# $Id: ackermann.python,v 1.2 2003/12/30 01:22:55 davidw Exp $
# http://www.bagley.org/~doug/shootout/
# from Brad Knotwell

# END COMMENT
import sys

def Ack(M, N):
    if (not M):
        return( N + 1 )
    if (not N):
        return( Ack(M-1, 1) )
    return( Ack(M-1, Ack(M, N-1)) )

def main():
    NUM = int(sys.argv[1])
    sys.setrecursionlimit(3000)
    print "Ack(3,%d): %d" % (NUM, Ack(3, NUM))

main()

Generated by GNU enscript 1.6.3.