Create multiply.js (#140)

Multiply Two numbers using Bit-wise Operator.
This commit is contained in:
Ujjwal Aryal 2018-08-10 20:09:45 +05:30 committed by Oleksii Trekhleb
parent cc3a5bd353
commit 53c7143e07

View File

@ -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;
}