Recursive function



Write a recursive function which returns the value of A(m,n). This function grows very quickly in value. This function A(m,n) is defined as:
if m=0 then n+1
if m>0 and n=0 then A(m-1,1)
if m>0 and n>0 then A(m-1,A(m,n-1))

Example
f(0 0)= 1
f(0 1)= 2
f(0 2)= 3
f(0 3)= 4
f(0 4)= 5
f(1 0)= 2
f(1 1)= 3
f(1 2)= 4
f(1 3)= 5
f(1 4)= 6
f(2 0)= 3
f(2 1)= 5
f(2 2)= 7
f(2 3)= 9
f(2 4)= 11
Smart pascal source code
function Ackermann(m, n : Integer) : Integer; begin if m = 0 then Result := n+1 else if n = 0 then Result := Ackermann(m-1, 1) else Result := Ackermann(m-1, Ackermann(m, n-1)); end; function Fx(a,b: Integer): Integer; begin Result := Ackermann(a, b); end; WriteLn(IntToStr(Fx(1,0))); // 2 WriteLn(IntToStr(Fx(2,1))); // 5 WriteLn(IntToStr(Fx(2,4))); // 11 {---} for var i := 0 to 3 do for var j := 0 to 4 do begin WriteLn( Ackermann(i,j) ); end; { 1,2,3,4,5, 2,3,4,5,6, 3,5,7,9,11, 5,13,29,61,125 }