Hi, I'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 :)
Hi,
ReplyDeleteI'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 :)