Non-recursive method for writing Ackerman function