I just came across the AckermannPter function a few weeks ago, found it to be very interesting, and decided to write a simple implementation of it in a favorite programming language of mine.def ackermann_peter_10(m, n):    assert isinstance(m, int) and m >= 0, 'm is unacceptable'    assert isinstance(n, int) and n >= 0, 'n is unacceptable'    stack = []    while True:        if not m:            if not stack:                return n + 1            m, n = stack.pop(), n + 1        elif not n:            m, n = m - 1, 1        else:            stack.append(m - 1)            n -= 1Can you refactor ackermann_peter_10 any further? It surprised me to see how similar the code is to another version found on Stack Overflow.Reference: Simple loop Ackermann function
Ackermann function
python;algorithm;python 3.x
I think the primary issue with your code is you can reasonably assume it will take forever on any hardware that may be running it for all but a handful of possible inputs.You can reasonably work out what those inputs are. If for instance m and n are bigger than 7, you should throw an error or return something like Infinity immediately. I haven't worked out the exact edge for when it's reasonable to compute the Ackermann function but you should.Another way to improve this function is to delete it. In your documentation you may explain why it's unreasonable to supply an implementation of the Ackermann function.