Suppose you have a decimal value like 0.4171 that is an exact or approximate representation of a fraction. Below is an R function I wrote that tries to determine which fractions could have produced that value.

Here’s an example run:

Here’s the function itself:

Advertisements