Created
March 23, 2018 22:28
-
-
Save andylshort/d0b91c36504e82e9185c02d205aafef7 to your computer and use it in GitHub Desktop.
Python implementation of the Ackermann function
This file contains 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
def Ackermann(x, y): | |
answer = 0 | |
if x == 0: | |
answer = y + 1 | |
elif y == 0: | |
answer = Ackermann(x - 1, 1) | |
else: | |
answer = Ackermann(x - 1, Ackermann(x, y - 1)) | |
return answer | |
for x in range(0, 6): | |
for y in range(0, 6): | |
print(Ackermann(x, y)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment