So how to I run Ackermann's Function without running into Segmentation fault (core dumped)
error because of my program tries to access/expand memory that it doesn't hace access to? Maybe expanding the memory limit of GCC to 256MB? It causes this error at about 9MB of memory usage. I run Manjaro Linux
Code:
#include<stdio.h>
int ack (int m, int n) {
if (m == 0)
return n + 1;
else if (n == 0)
return ack(m - 1, 1);
else
return ack(m - 1, ack(m, n - 1));
}
int main() {
int i, j;
for (i = 0; i <= 5; i++)
for (j = 0; j <=5; j++)
printf("Result for ackermann(%d, %d) is: %d\n",i, j, ack(i, j));
return 0;
}
Code added for reproducing results