public class Solution {
public int aplusb(int a, int b) {
// write your code here
// a^b;//10^11=01沒有進位
// a&b //10&11=10 說明第2個數有進位,但是進位在高位(第3位)
// <<1 //左移動一位 就是100
// 最後把結果再進^操作給a,直到沒有進位
if (b == 0)//有1代表還有進位
return a;
else
return aplusb(a^b, (a&b) << 1);
}
};