Skip to content

Instantly share code, notes, and snippets.

@timothyandrew
Created April 16, 2013 07:23
Show Gist options
  • Save timothyandrew/5394047 to your computer and use it in GitHub Desktop.
Save timothyandrew/5394047 to your computer and use it in GitHub Desktop.
int add(int a, int b) {
if(b == 0) return a;
return 1 + add(a, b - 1);
}
int subtract(int a, int b) {
if(b == 0) return a;
return subtract(a, b - 1) - 1;
}
int main() {
int a = 5, b = 10;
a = add(a,b);
b = subtract(a,b);
a = subtract(a,b);
printf("%d\n%d\n", a,b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment