selinap.com

To leave furtively and stealthily.

Home » Python

Evaluate Ankermann Function using Python

August 10th, 2008

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

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

1
2
3
4
5
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.

Random Articles:

Popular Articles:

Spread/Promote this article.

Digg | Del.icio.us | Stumble | Y! MyWeb | Y! Buzz | Fave It! | Reddit

Subscribe for free.

 Subscribe to Selinap.com feed right now!

 Get Updates by Email

Tags:

One Response to “Evaluate Ankermann Function using Python”

  1. KNizam says:

    perghhhh to mathematical for me. hehe :mrgreen:
    KNizams last blog post..Latest Photos/Pictures Published Online for the Beijing 2008 Olympic Games !

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> <pre lang="" line="">


© Copyright 2008 - 2009 selinap.com
Entries (RSS) and Comments (RSS).