KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm finding it difficult to understand how the Ackermann Function works. I think my understanding of recursion is flawed? Here is the code in Python: def naive_ackermann(m, n): global calls calls += 1 if m == 0: return n + 1 elif n == 0: return naive_ackermann(m - 1, 1) else: return naive_ackermann(m - 1, naive_ackermann(m, n - 1)) If I do the function call of naive_ackermann(3,4), how and why do I end up getting 125? Comments will be appreciated. Thanks
Tags (comma-separated)
Save Edits
Cancel