Skip to content

Instantly share code, notes, and snippets.

@tamlt2704
Created December 31, 2017 11:40
Show Gist options
  • Select an option

  • Save tamlt2704/8993543766b12cde81641345cda6d268 to your computer and use it in GitHub Desktop.

Select an option

Save tamlt2704/8993543766b12cde81641345cda6d268 to your computer and use it in GitHub Desktop.
# Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.
int getSum(int a, int b) {
if (b)
return getSum(a ^ b, (a & b) << 1);
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment