Ackermann Function with Caching