Question: Too many levels of recursion error (Ackermann function)

Hello :)

I'm trying to write an Ackermann function on Maple, here is the source:

> B := (n, a, x) -> if n=0 then a+x elif n=1 then a*x elif n=2 then a^x elif x=1 then a else B(n-1,a,B(n,a,x-1)) end if:
> A := (n, x) -> B(n,2,x):

With small cases it works perfectly, for example:
A(3,3);
    16
but... when i'm trying to calc A(5,5), i get an "Error, (in B) too many levels of recursion". Any ideas?

Please Wait...