Skip to content

Instantly share code, notes, and snippets.

@joker8023
Created August 3, 2018 04:31
Show Gist options
  • Save joker8023/6304964fd5f47d689d9a64ed04daacff to your computer and use it in GitHub Desktop.
Save joker8023/6304964fd5f47d689d9a64ed04daacff to your computer and use it in GitHub Desktop.
aplusb
def aplusb(a, b):
if (a == 0):
return b
if (b == 0):
return a
i = a ^ b
sum = (a & b) << 1
return aplusb(sum, i)
if __name__ == '__main__':
print(aplusb(3, 5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment