It's easy for us to tell that 0.49999 is only 0.00001 away from being expressed as a simple ratio: 1/2.
However, it may not be as obvious that 0.142858 is also at most only 0.00001 away from being expressed as a simple ratio. 1/7 in this case.
For our purpose a simple ratio will be defined as a fraction where both the numerator and the denominator consist of a single digit.
Is there a way to calculate the closest simple ratio to a number other than comparing the difference between every ratio and the number in question?
How would you generalize this to approximating simple ratios using integers up to n for the numerator and denominator?