Skip to content

Instantly share code, notes, and snippets.

@timothyandrew
Last active December 16, 2015 06:49
Show Gist options
  • Save timothyandrew/5394055 to your computer and use it in GitHub Desktop.
Save timothyandrew/5394055 to your computer and use it in GitHub Desktop.
int add(int a, int b) {
if(b == 0) return a;
b--;
return 1 + add(a, b);
}
int subtract(int a, int b) {
if(b == 0) return a;
b--;
return subtract(a, b) - 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