Recent News int ack(m,n)
int m,n;
{
int ans;
if (m == 0) ans = n+1;
else if (n == 0) ans = ack(m-1,1);
else ans = ack(m-1, ack(m,n-1));
return (ans);
}

int main (argc, argv)
int argc; char ** argv;

{ int i,j;
for (i=0; i<6; i++)
for (j=0;j<6; j++)

printf (“ackerman (%d,%d) is: %dn”,i,j, ack(i,j));
}We declare the recursive function as ‘ack’ for short .It is a function with two incoming integer arguments. It delivers back an integer result. It delivers the interger result in it local variable ‘ans’. But how does it do its recursive horrors? If the incoming argument ‘m’ is zero, then deliver back the integer answer n+1. So if I came in with ack(0,2), because m = = 0 it will deliver back 3 as an answer. Easy, isn’t it? Now, if that isn’t true, else if n = = 0 then the answer is what you get by calleing up Ackermann recusrsively but this time by reducing m by 1 and with the second argument as 1 i.e ack(m-1,1). If you think that’s not bad enough then here comes the next killer. If m isn’t 0 and n isn’t 0 then what’s the genral case? The general case is the answer of ack(m-1,ack(m,n-1)). Notice that in the first argument we are reducing the value of m and the next argument is where your brain cries in pain. Think about the second argument more. It makes you realise why you can’t de-recurse this by some iterative methods. The second argument for that generalised call of Ackermann is itself a call of Ackermann. So you have to go through endless, countless stackframes just to calculate what the second argument must be. Makes you just go through the same agony all over again. Here I would like to draw your attention to the fact that everytime m and n are altered in going around recursively, theyreduce. Now when m and n is reduced to 0 and for that the traps that you have written i.eif (m == 0) ans = n+1;
else if (n == 0) ans = ack(m-1,1);then and only then the program will terminate. But one thing I would like to mention here is, if you really want an output ever (however long it might take to produce it) then you must feed in 0 or some positive integers as the arguments i.e 0<=m,0<=n. If you are willing to test this with negative integers then good luck for that. Let me know what happened.
The most important thing here is, although the program will produce millions and millions of stackframes but because you are reducing the value of m and n, you can (with valid reasons of course) can convince yourself that eventually the program will terminate. Again, by saying this I am trying to highlight the fact that this problem is a regular recursion and not the recursively enumerable one. News Reporter