secret
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#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;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.