Originally Posted by gonfreecks
Ackerman function requires a lot of recursion.
Once a function goes too deeply in its recursion a java.lang.StackOverflowError occurs.
On my machine (Windows XP, 1 GB of memory) I tried a dummy recursive function and an StackOverflowError occured on recursion depths 6236 and 6260.
With Ackerman function once there is a calculation of expression like A(m,n) and m and n are positive numbers,it is going to recurse at least as deep as n-1.
For example if we have A(1,10000) it is going to recurse
A(1,10000)=A(0,A(1,9999))=A(0,A(0,A(0,A(1,9998)))= A(0,A(0,A(0,A(0,A(1,9997))))...... A(0,...A(1,0)) and it is already at recursion depth of
9999 which is greater than 6236 or 6260 on which the dummy function caused the exception on my computer.
While calculating A(4,3) the recursive calls which follow involve calls with much greater n than 10000, which we maybe can think of as some recursion depth limit.
For example, there must be a call to A(3,2^65536-3) while calculating A(4,3)
(Ackermann function - Wikipedia, the free encyclopedia
which would require recursion depth of at least 2^65536-4 , and that is way greater than 10000.
Even with A(4,1) there are calls A(m,n) with n greater than 4000 , and which cause exception on my computer.
So, A(4,3) recurses way too deep.
Hope it helped,