In my home work of Ackermann function I have solved the problem as following
int main()
{
int y = ack(4,1);
cout<<"ans is :::: "<< y;
getch();
return 0;
}
int ack(int m, int n)
{
if(m == 0)
{
return n+1;
}
else if(m > 0 && n == 0)
{
return ack(m-1,1);
}
else if(m > 0 && n>0)
{
int x = ack(m,n-1);
return ack(m-1,x);
}
else
{
cout<< "did not worked properly";
}
}
This function works great with low values upto m=3 and n = 10 But when I give m = 4/above or n = 15/above this don't work. I get no out put. Program just exit without any warning or error or result.
Please some body tell me the reason why this is happening and how can I solve this problem.