How to convert decimal to fraction?

In this question, if I try to make convert 0.3333333 to fraction using this method,

x = 0.333333

10x = 3. 333333

9x = 3

x = \frac{1}{3}

then, it doesn’t work for fractions like 0.25 or any other fraction. What should I do? To manage stuff like this?

Here you can calculate numerator and denominator separately and then divide them with their gcd (greatest common divisor) and then output accordingly.


For some helpful tips or additional support in such specialized questions, you may refer to custom paper writing services. or at least give a try to have them provide you with appropriate material.