Files
freeCodeCamp/curriculum/challenges/english/10-coding-interview-prep/project-euler/problem-57-square-root-convergents.md
Oliver Eyton-Williams ee1e8abd87 feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

61 lines
1.5 KiB
Markdown

---
id: 5900f3a51000cf542c50feb8
title: 'Problem 57: Square root convergents'
challengeType: 5
forumTopicId: 302168
dashedName: problem-57-square-root-convergents
---
# --description--
It is possible to show that the square root of two can be expressed as an infinite continued fraction.
<div style='text-align: center;'>$\sqrt 2 =1+ \frac 1 {2+ \frac 1 {2 +\frac 1 {2+ \dots}}}$</div>
By expanding this for the first four iterations, we get:
$1 + \\frac 1 2 = \\frac 32 = 1.5$
$1 + \\frac 1 {2 + \\frac 1 2} = \\frac 7 5 = 1.4$
$1 + \\frac 1 {2 + \\frac 1 {2+\\frac 1 2}} = \\frac {17}{12} = 1.41666 \\dots$
$1 + \\frac 1 {2 + \\frac 1 {2+\\frac 1 {2+\\frac 1 2}}} = \\frac {41}{29} = 1.41379 \\dots$
The next three expansions are $\\frac {99}{70}$, $\\frac {239}{169}$, and $\\frac {577}{408}$, but the eighth expansion, $\\frac {1393}{985}$, is the first example where the number of digits in the numerator exceeds the number of digits in the denominator.
In the first one-thousand expansions, how many fractions contain a numerator with more digits than denominator?
# --hints--
`squareRootConvergents()` should return a number.
```js
assert(typeof squareRootConvergents() === 'number');
```
`squareRootConvergents()` should return 153.
```js
assert.strictEqual(squareRootConvergents(), 153);
```
# --seed--
## --seed-contents--
```js
function squareRootConvergents() {
return true;
}
squareRootConvergents();
```
# --solutions--
```js
// solution required
```