Question is to Divide two integers without using multiplication, division and mod operator.
How should our approach be?
Question is to Divide two integers without using multiplication, division and mod operator.
How should our approach be?
If you want z=x/y then basically, zy=x. If you find one such z satisfying this condition using binary search, your task is done. As you restricted to use multiplication either, i will use addition and add z, y times in order to get zy. Complexity of this approach is O(y*log(x)).
A better solution may exist.
Thank you for the pointer. I shall think over it!