Evaluate Ankermann Function using Python

Sunday, August 10th, 2008
Advertisement

Subscribe.
Enter your email:

The Ankermann function, A(m, n) is defined as

The Python code below could be used to evaluate the Ankermann function.

def ack(m,n):
    if m == 0: return n+1
    elif m > 0:
        if n == 0: return ack(m-1, 1)
        elif n > 0: return ack(m-1, ack(m, n-1))

Usage:

ack(3, 4)

However, this code can’t be used for larger values of m and n.

If you are new here, you might want to subscribe to the RSS feed or newsletter.

Enter your email address:

Creates the exact copy of your hard disk and allows you to instantly restore the entire machine.
New Acronis True Image Home 2010 is the most reliable and easy in use backup solution. Now with online backup option!
15% Discount Code: FMAATIH2010

What else should you read?

    Like this article? Share it

     Digg  del.icio.us  TwitThis  Facebook  Reddit  StumbleUpon

    One Response to “Evaluate Ankermann Function using Python”

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>