Problem D
Dead Fraction
To make this tenable, he assumes that the original fraction is always the simplest one that produces the given sequence of digits; by simplest, he means the the one with smallest denominator. Also, he assumes that he did not neglect to write down important digits; no digit from the repeating portion of the decimal expansion was left unrecorded (even if this repeating portion was all zeroes).
Input
There are several test cases. For each test case there is one line of input of the form “0.dddd...” where dddd is a string of $1$ to $9$ digits, not all zero. A line containing 0 follows the last case.
Output
For each case, output the original fraction.
Sample Input 1 | Sample Output 1 |
---|---|
0.2... 0.20... 0.474612399... 0 |
2/9 1/5 1186531/2500000 |