Sum of two integers | SoloLearn: Learn to code for FREE!

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

4/14/2018 5:30:34 AM

Anthony Perez

3 Answers

New Answer

+6

>>> a = 1 >>> b = 2 >>> print a.__add__(b) 3

+2

#Python print(sum([5,7]))

+2

#Python def sumbin(a,b): if (a&b)==0: return a^b return sumbin((a&b)<<1,a^b) print(sumbin(7,33))