All irreducible fractions whose denominators do not exceed 99 are written in ascending order from left to right (Quantum magazine)
All irreducible fractions whose denominators do not exceed 99 are written in ascending order from left to right. What are the fractions  $\dfrac{a}{b}$ and $\dfrac{c}{d}$  on each side of  $\dfrac{5}{8}?$
I have no idea to solve this problem. Can someone give me a hint?
Thanks for antetion
 A: First of all, it should be clear that once we solve the problem for one side, the second side will be done similarly.
So let
$$\frac{a}{b} < \frac{5}{8}\tag{1}$$
with $b \leq 99$.
Now, let $a$ be fixed, then from $(1)$ we get $$\frac{8a}{5}<b\tag{2}.$$ In order to maximize $a/b$, we want to minimize $b$ for fixed $a$, so we want to choose next integer after $8a/5$. To see what integer this will be, we can inspect $5$ cases based on remainder of $a$ divided by $5$.
For example, if $a \equiv 0 \bmod {5}$, then $(2)$ gives us $b \geq \frac{8a}{5}+1$, and so $b$ is minimized for $b=\frac{8a}{5}+1$. But then considering $a$ was chosen arbitrary, we will choose maximal $a$ such that $b=\frac{8a}{5}+1\leq 99$ and $a \equiv 0 \bmod {5}$. The inequality simplifies to $a \leq 61$ (since $a$ is an integer), and so maximal $a$ is with $a=60$, and thus $b=97$.
Doing this process for all $a\equiv 0,1,2,3,4 \bmod 5$, we will obtain $\frac{a}{b}=\frac{60}{97}$,$\frac{61}{98}$,$\frac{57}{92}$,$\frac{58}{93}$,$\frac{59}{95}$, respectively. Directly comparing the five possibilities, we can see that maximum is at $$\frac{a}{b}=\frac{58}{93}.$$
