Simple solution using Exponents and Log : faster then 92%
Exponent and Log Solution\n\nI wanted to submit a different solution compared to all the other bit manipulation ones. (which I do suggest you check out )\n\nSte
# Exponent and Log Solution\n\nI wanted to submit a different solution compared to all the other bit manipulation ones. (which I do suggest you check out )\n\n**Step 1:**\nThe logic is simple first we use the **Exponent Rule of Multiplication** which states:\n\n&nbsp;&nbsp;&nbsp;&nbsp; ![image](https://assets.leetcode.com/users/images/66d4ebde-04eb-4da0-b007-48fcc64a6768_1633787067.6651442.png)\n \n Lets call the two numbers we need to add *num1* and *num2*.\n Therefore as long as we use the same base, we can raise that common base to *num1* and *num2* and multiply them.\n In this code I have chosen the common base of 2 but you can choose any number.\n \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**2<sup> *num1*</sup> x 2<sup> *num2*</sup> = 2<sup> *num1 + num2* </sup>**\n\nLets call this result *product*.\n\n**Step 2:**\nNext we use the **Log of Exponent Rule** (Logarithm of a Base to a Power Rule), which states\n  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**log<sub>a</sub>(a<sup>*n*</sup> ) = n**\n  \n  In our case we take log base 2 of *product* which gives us the sum of  *num1* and *num2* .\n\n  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**log<sub>2</sub>(2<sup> *(num1 + num2)* </sup> ) = *num1 + num2***\n  \n  And that is the final answer.\n  \n  \n  \n\n\n\n```\nimport math\nclass Solution:\n    def getSum(self, a: int, b: int) -> int:\n        #raises 2 to the power a\n        fact1=math.pow(2,a)\n        #raises 2 to the power b\n        fact2=math.pow(2,b)\n        #by multiplying the 2 factors, the powers gets added\n        #ie, 2^(a+b)\n        prod=fact1*fact2\n        """\n         here we use the Log of Exponent Rule \n            -> log2(2^(a+b)) = a+b\n         """\n        ans=math.log2(prod)\n        return int(ans)                                      \n```\n\nLet me know if there is any way to make this more efficent.
['Python']