mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-05 05:18:44 -05:00
1.2 KiB
1.2 KiB
id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName |
|---|---|---|---|---|
| 5900f42c1000cf542c50ff3f | Problem 192: Beste Annäherungen | 1 | 301830 | problem-192-best-approximations |
--description--
x sollte eine reelle Zahl sein.
Eine beste Annäherung an x für die Nennergrenze d ist eine rationale Zahl \frac{r}{s} in reduzierter Form, mit s ≤ d, sodass jede rationale Zahl, die näher an x liegt als \frac{r}{s}, einen Nenner größer als d hat:
|\frac{p}{q} - x| < |\frac{r}{s} - x| ⇒ q > d
Zum Beispiel, die beste Annäherung an \sqrt{13} für die Nennergrenze 20 ist \frac{18}{5} und die beste Annäherung an \sqrt{13} für die Nennergrenze 30 ist \frac{101}{28}.
Finde die Summe aller Nenner der besten Näherungen an \sqrt{n} für die Nennergrenze {10}^{12}, wobei n kein perfektes Quadrat ist und 1 < n ≤ 100000.
--hints--
bestApproximations() sollte 57060635927998344 zurückgeben.
assert.strictEqual(bestApproximations(), 57060635927998344);
--seed--
--seed-contents--
function bestApproximations() {
return true;
}
bestApproximations();
--solutions--
// solution required