Ackermann

It’s named after Wilhelm Ackermann, is one of the simplest and earliest-discovered examples of a total computable function that is not primitive recursive. All primitive recursive functions are total and computable, but the Ackermann function illustrates that not all total computable functions are primitive recursive.

After Ackermann's publication of his function (which had three nonnegative integer arguments), many authors modified it to suit various purposes, so that today "the Ackermann function" may refer to any of numerous variants of the original function. One common version, the two-argument Ackermann–Péter function, is defined as follows for nonnegative integers m and n: $n!!=\begin{cases}1,&\text{if }n=0\text{ or }n=1;\\n\times(n-2)!! &\text{if }n\ge2.\qquad\qquad\end{cases}$

Its value grows rapidly, even for small inputs. For example A(4,2) is an integer of 19,729 decimal digits.

Ackermann's original three-argument function $n!!=\begin{cases}1,&\text{if }n=0\text{ or }n=1;\\n\times(n-2)!! &\text{if }n\ge2.\qquad\qquad\end{cases}$ is defined recursively as follows for nonnegative integers m, n, and p: $n!!=\begin{cases}1,&\text{if }n=0\text{ or }n=1;\\n\times(n-2)!! &\text{if }n\ge2.\qquad\qquad\end{cases}$

Of the various two-argument versions, the one developed by Péter and Robinson (called "the" Ackermann function by some authors) is defined for nonnegative integers m and n as follows: $n!!=\begin{cases}1,&\text{if }n=0\text{ or }n=1;\\n\times(n-2)!! &\text{if }n\ge2.\qquad\qquad\end{cases}$

It may not be immediately obvious that the evaluation of always terminates. However, the recursion is bounded because in each recursive application either m decreases, or m remains the same and n decreases. Each time that n reaches zero, m decreases, so m eventually reaches zero as well. (Expressed more technically, in each case the pair (m, n) decreases in the lexicographic order on pairs, which is a well-ordering, just like the ordering of single non-negative integers; this means one cannot go down in the ordering infinitely many times in succession.) However, when m decreases there is no upper bound on how much n can increase — and it will often increase greatly.