Created
February 19, 2015 21:34
-
-
Save ejmurray/521c2682c03eaa3e5f31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This module contains code from | |
Think Python by Allen B. Downey | |
http://thinkpython.com | |
Copyright 2012 Allen B. Downey | |
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html | |
""" | |
def ackermann(m, n): | |
"""Computes the Ackermann function A(m, n) | |
See http://en.wikipedia.org/wiki/Ackermann_function | |
n, m: non-negative integers | |
""" | |
if m == 0: | |
return n+1 | |
if n == 0: | |
return ackermann(m-1, 1) | |
return ackermann(m-1, ackermann(m, n-1)) | |
print (ackermann(3, 4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment