Skip to content

Instantly share code, notes, and snippets.

@andylshort
Created March 23, 2018 22:28
Show Gist options
  • Save andylshort/d0b91c36504e82e9185c02d205aafef7 to your computer and use it in GitHub Desktop.
Save andylshort/d0b91c36504e82e9185c02d205aafef7 to your computer and use it in GitHub Desktop.
Python implementation of the Ackermann function
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