This problem is related to Farey sequences , the Stern -- Brocot tree , and continued fractions .
This problem is related to Farey sequences , the Stern-Brocot tree , and continued fractions .