= McCarthy 91 function
{c}
{title2=$M(n)=n>100?\,n-10:\,M(M(n+11))$}
The <McCarthy 91 function> is the nested recursive <integer> <function>
$$
M(n)=\begin{cases}n-10,&n>100,\\M(M(n+11)),&n\leq100.\end{cases}
$$
Its result is $91$ for every $n\leq101$ and $n-10$ for $n>101$. For instance, $M(100)=M(M(111))=M(101)=91$. The striking feature is that the recursive case first increases its argument and then makes a second recursive call, so a naive decreasing-argument termination argument fails. It is a standard example for reasoning about nested <recursion> and proving equivalence between a recursive definition and a simple piecewise <function>.
Back to article page