Skip to content

Instantly share code, notes, and snippets.

Created May 30, 2013 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0a83f05b6d0c3727b0c9 to your computer and use it in GitHub Desktop.
Save anonymous/0a83f05b6d0c3727b0c9 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <iostream>
using namespace::std;
int mcCarthy91(int n,int & output)
{
if(n>100)
{
printf("M(%d) since %d is greater than 100\n",output-10,output);
output-=10;
return n - 10;
}
else
{
printf("M(M(%d)) since %d is less than 100\n",output+11,n);
output+=11;
return mcCarthy91(mcCarthy91(n+11,output),output);
}
}
int main()
{
int n = 50;
std::cout<<"please enter an int"<<endl;
cin>>n;
printf("M(%d)\n",n);
int out = mcCarthy91(n,n);
printf("output is %d",out);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment