diff --git a/src/algorithms/math/bits/multiply.js b/src/algorithms/math/bits/multiply.js new file mode 100644 index 00000000..8755d6be --- /dev/null +++ b/src/algorithms/math/bits/multiply.js @@ -0,0 +1,14 @@ +/** + * @param {number, number} + * @return {number} + */ +export default function multiply(number1, number2) { + var c = 0, result = 0; + while(number2){ + if(number2&1) + result += (number1 << c); + c += 1; + number2 >>= 1; + } + return result; +}