+ 1
Sum of two integers
How do you get the sum without using the operators +, - with python??? Here is my code: class Solution: def getSum(self, a, b): print(sum1,2) my problem is returning the integer 3 ??
2 odpowiedzi
+ 5
>>> a = 1
>>> b = 2
>>> print a.__add__(b)
3
+ 2
#Python
def sumbin(a,b):
if (a&b)==0: return a^b
return sumbin((a&b)<<1,a^b)
print(sumbin(7,33))