One liner with detailed explanation
The chosen answer from this post: [adding-two-numbers-without-operator-clarification][1] helps me understand how it works, and recursion proves to be more intui
The chosen answer from this post: [adding-two-numbers-without-operator-clarification][1] helps me understand how it works, and recursion proves to be more intuitive to me than iterative.\nBasically, with key points:\n\n1. exclusive or (***^***) handles these cases: 1+0 and 0+1 \n2. AND (***&***) handles this case: 1+1, where ***carry*** occurs, in this case, we'll have to shift carry to the left, why? Think about this example: 001 + 101 = 110 (binary format), the least significant digits of the two operands are both '1', thus trigger a carry = 1, with this carry, their least significant digits: 1+1 = 0, thus we need to shift the carry to the left by 1 bit in order to get their correct sum: 2\n\nMy initial submission with inspiration from that post:\n\n    public int getSum(int a, int b) {\n        if(b == 0) return a;\n        int carry = (a & b) << 1;\n        int sum = a ^ b;\n        return getSum(sum, carry);\n    }\n\nThen I found the above solution could be shortened to one-liner:\n\n    public int getSum(int a, int b) {\n        return b == 0 ? a : getSum(a^b, (a&b)<<1);\n    }\n\n\n  [1]: http://stackoverflow.com/questions/9070937/adding-two-numbers-without-operator-clarification
['Java']