McCarthy 91
Think Recursion is cool ? Check out the McCarthy 91 recursive function. Conceived by computer scientist John McCarthy, it takes the value 91 for all positive integers less than 102. Here is the C implementation ,
/* McCarthy 91 Recursive Function -
* for 0 <= n < 102,
* M(n) = { n - 10, if n > 100
* { M(M(n+11)), if n <= 100
*/
unsigned int M(unsigned int n)
{
if (n > 100)
return n - 10;
else {
return M(M(n+11));
}
}
|
TopicsRecent blog posts
|