Saturday, December 5, 2009
Dividing a number with no division
This could be an interview question, but do not expect me to ask this question anymore ;-)
"Given a>0 can you compute a^-1 without any division?"
"Given a>0 can you compute a^-1 without any division?"
Subscribe to:
Post Comments (Atom)
1 comment:
Hi,
Reply DeleteI'll try to give the soln by an example .. say a = 19
we need to find 1/19, since 1 < 19, we take 10 still 10 < 19, now we take 100, 100 is > 19 and (by binary searching ) we know 19*5 < 100 < 19*6 so, we construct the result as 0.05, now 100-95 = 5, again 5 < 19, so 50 (5*10), 50 > 19 and we find 19*2 < 50 < 19*3 so, our result extends to 0.052 and the new remainder is 50-19*2 = 12, now 120 > 19 .. so we carry on ..
nice qns btw :)