function mulByAdd(a, b) {
var iter = function (res, a, b) {
if (b == 0) {
return res;
}
if (b % 2 == 0) {
return iter(res, a << 1, b >> 1)
}
return iter(res + a, a, b - 1)
}
return iter(0, a, b);
}
Created
June 7, 2016 11:42
-
-
Save jougene/58173d8e584cfb6b7e9680e90ba72cab to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
b & 1 == 0