educative.io

Hi, may I know why the remainder is multiplied with 10 everytime?

remainder = (numerator % denominator) * 10

Hello @Venukumar_B_V,

When converting a fraction to a decimal using the long division method, the remainder of each division is multiplied by 10. Doing so enables the calculation of the next digit. This approach ensures a precise and accurate representation of the fraction in its decimal form.

You can try this out by doing a long division of 8/666 by hand, where you’ll get a recurring pattern 0.012012…

Hope this answers your query. Feel free to drop in more queries and suggestions. Thanks!

2 Likes

Great ! Thanks a lot @Dian_Us_Suqlain :slight_smile:

1 Like