Skip to content

Instantly share code, notes, and snippets.

@not-for-me
Last active November 4, 2015 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save not-for-me/2c02e41b6f28bd71bc00 to your computer and use it in GitHub Desktop.
Save not-for-me/2c02e41b6f28bd71bc00 to your computer and use it in GitHub Desktop.
tail recursion version: two's exponential function
int _twoExponential(int exponent, int acc) {
if ( exponent == 0 ) {
return acc;
}
acc *= 2;
return _twoExponential(--exponent, acc);
}
int exponential(int num) {
return _twoExponential(num, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment