/gist:0a83f05b6d0c3727b0c9 Secret
Created
May 30, 2013 15:07
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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