Comments by "robheusd" (@robheusd) on "The Most Difficult Program to Compute? - Computerphile" video.
-
/* Is there a pattern of Ackermann functions ?? */
int ack0()
{
return 1;
}
int ack1(int n)
{
if (n == 0) return ack0();
else return ack1(n - 1);
}
int ack2(int m, int n)
{
if (m == 0) return ack1(n) + ack0();
else if (n == 0) return ack2(m - 1, ack0());
else return ack2(m - 1, ack2(m, n - 1));
}
// Then ack3 would be something like this ??
int ack3(int k, int l, int m)
{
if (k == 0) return ack2(l, ack1(m)) + ack1(m) + ack0();
else (if l == 0) return ack2(k - 1, ack2(1, m));
else if (m == 0) return ack3(k - 1, ack2(l, m - 1)), ack0());
else return ack3(k - 1, ack3(k, ack2(l, m) , ack2(l, m - 1)) - 1, ack2(l - 1, ack2(l, m) - 1));
}
......
int ackn(int n, int x[n])
{
// ???? Could we even express the function in C ???
}
1