+ 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 ??

14th Apr 2018, 5:30 AM
Anthony Perez
2 ответов
+ 5
>>> a = 1 >>> b = 2 >>> print a.__add__(b) 3
14th Apr 2018, 6:13 AM
ƒred
ƒred - avatar
+ 2
#Python def sumbin(a,b): if (a&b)==0: return a^b return sumbin((a&b)<<1,a^b) print(sumbin(7,33))
14th Apr 2018, 7:02 AM
Edward
Edward - avatar