Microsoft Interview Question

Given 2 integer, return their multiplication without using the multiplication operator

Interview Answers

Anonymous

Oct 31, 2017

Recursion. Manipulate only one of the two integers, let’s say y. If y is 0 then return 0. If y is greater than 0, call the same function with y-1 and return the sum of its result and x. Do not forget the case where y is negative (call the function with -y, and return the opposite)

Anonymous

Jan 16, 2022

function(a,b) { return (a << floor(log2(b))) + b%2==0?0:b; }

Anonymous

Nov 29, 2016

Bit manipulation