## A best approximation to a real number $x$ for the denominator bound $d$ is a rational number $\frac r s$ (in reduced form) with $s \le d$, so that any rational number $\frac p q$ which is closer to $x$ than $\frac r s$ has $q \gt d$.

Usually the best approximation to a real number is uniquely determined for all denominator bounds. However, there are some exceptions, e.g. $\frac 9 {40}$ has the two best approximations $\frac 1 4$ and $\frac 1 5$ for the denominator bound $6$.

We shall call a real number $x$ ambiguous, if there is at least one denominator bound for which $x$ possesses two best approximations. Clearly, an ambiguous number is necessarily rational.

How many ambiguous numbers $x=\frac p q, 0 \lt x \lt \frac 1 {100}$, are there whose denominator $q$ does not exceed $10^8$?

### To solve this problem, we have to dive into a part of Number Theory called Diophantine approximation.

Let’s denote by $a/b$ a best approximation to a number $x=c/d$ for the denominator bound $b$. By definition, for any approximation $p/q$ which is closer to $x$ than $a/b$, we must have $q>b$.

This leads to the inequality $\left| \frac{c}{d} – \frac{a}{b} \right| < \frac{1}{bq}$.
Therefore, we have $ \frac{1}{b \cdot q} < \left| \frac{c}{d} - \frac{a}{b} \right| < \frac{1}{b \cdot (b+1)}$.
This needs to hold for at least two $b$. Let's denote them by $b_1$ and $b_2$ and their respective approximating numerators by $a_1$ and $a_2$. Hence, we have:
$\frac{1}{b_1 \cdot (b_1+1)} < \left| \frac{c}{d} - \frac{a_1}{b_1} \right| < \frac{1}{b_1 \cdot b_2}$, and
$\frac{1}{b_2 \cdot (b_2+1)} < \left| \frac{c}{d} - \frac{a_2}{b_2} \right| < \frac{1}{b_1 \cdot b_2}$.
The general solution to this system is given by
$c = i \cdot \left[ \frac{b_1 \cdot b_2}{b_1 + b_2} \right]$ and $b_1

Prime Triplets

A Recursively Defined Sequence