← Complete problem index

PROJECT EULER · #0192

Best Approximations

Statement only · SolvedOriginal problem ↗

Let x be a real number.
A best approximation to x for the denominator bound d is a rational number rs in reduced form, with sd, such that any rational number which is closer to x than rs has a denominator larger than d:

|pqx|<|rsx|q>d

For example, the best approximation to 13 for the denominator bound 20 is 185 and the best approximation to 13 for the denominator bound 30 is 10128.

Find the sum of all denominators of the best approximations to n for the denominator bound 1012, where n is not a perfect square and 1<n100000.

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.