Files
gikf 5a52c229f5 fix(curriculum): clean-up Project Euler 181-200 (#42819)
* fix: clean-up Project Euler 181-200

* fix: corrections from review

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

* fix: missing delimiter

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
2021-07-15 15:52:14 +02:00

1.2 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5900f42c1000cf542c50ff3f Problem 192: Best Approximations 5 301830 problem-192-best-approximations

--description--

Let x be a real number.

A best approximation to x for the denominator bound d is a rational number \frac{r}{s} in reduced form, with s ≤ d, such that any rational number which is closer to x than \frac{r}{s} has a denominator larger than d:

|\frac{p}{q} - x| &lt; |\frac{r}{s} - x| ⇒ q > d

For example, the best approximation to \sqrt{13} for the denominator bound 20 is \frac{18}{5} and the best approximation to \sqrt{13} for the denominator bound 30 is \frac{101}{28}.

Find the sum of all denominators of the best approximations to \sqrt{n} for the denominator bound {10}^{12}, where n is not a perfect square and 1 &lt; n ≤ 100000.

--hints--

bestApproximations() should return 57060635927998344.

assert.strictEqual(bestApproximations(), 57060635927998344);

--seed--

--seed-contents--

function bestApproximations() {

  return true;
}

bestApproximations();

--solutions--

// solution required