Skip to content

Instantly share code, notes, and snippets.

Created May 30, 2013 15:07
#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