The Ackermann function is non primitive recursive (See the wikipedia article).
Is there any way to run ack(3,14) without using d:danger. Using
-d:nimCallDepthLimit does not work since the value must be a 16 bit int.
proc ack(m,n:int) : int =
if m == 0 :
return n+1
elif n > 0 :
return ack(m-1,ack(m,(n-1)))
elif n == 0 :
return ack(m-1,1)
else:
echo "ack: bad m or n value"
Run
- Problem with a highly recursive function DougT
