#include <stdio.h>
#define MAXSIZE 100
int memo[MAXSIZE][MAXSIZE];
int aukermann(int m, int n)
{
if (memo[m][n] != -1)
return memo[m][n];
if (m == 0)
return (memo[m][n] = n + 1);
else if (n == 0)
return (memo[m][n] = aukermann(m - 1, 1));
else {
memo[m][n-1] = aukermann(m, n-1);
return (memo[m][n] = aukermann(m - 1, memo[m][n-1]));
}
}
main()
{
int m, n;
int i,j;
for (i = 0; i < MAXSIZE; ++i)
for (j = 0; j < MAXSIZE; ++j)
memo[i][j] = -1;
scanf("%d %d", &m, &n);
printf("%d\n", aukermann(m, n));
for (i = 0; i < 5; ++i) {
for (j = 0; j < 62; ++j)
printf("%d ", memo[i][j]);
printf("\n");
}
return 0;
}
Its is showing correct result till (2,48) then showing wrong answers for m = 2 and n >= 49 due to which I'm getting wrong answer for m = 3 n >= 4.
Please Help!