Created
August 3, 2018 04:31
-
-
Save joker8023/6304964fd5f47d689d9a64ed04daacff to your computer and use it in GitHub Desktop.
aplusb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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