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

172 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 5900f3851000cf542c50fe98
title: 问题251000位斐波纳契数
challengeType: 5
videoUrl: ''
dashedName: problem-25-1000-digit-fibonacci-number
---
# --description--
Fibonacci序列由递归关系定义
F
<sub>n</sub>
= F
<sub>n-1</sub>
- F
<sub>n-2</sub>
其中F
<sub>1</sub>
= 1且F
<sub>2</sub>
= 1。
因此前12个学期将是
F
<sub>1</sub>
= 1
F
<sub>2</sub>
= 1
F
<sub>3</sub>
= 2
F
<sub>4</sub>
= 3
F
<sub>5</sub>
= 5
F
<sub>6</sub>
= 8
F
<sub>7</sub>
= 13
F
<sub>8</sub>
= 21
F
<sub>9</sub>
= 34
F
<sub>10</sub>
= 55
F
<sub>11</sub>
= 89
F
<sub>12</sub>
= 144
第12个学期F
<sub>12</sub>
是第一个包含三位数的术语。 Fibonacci序列中包含`n个`数字的第一项的索引是多少?
# --hints--
`digitFibonacci(5)`应该返回21。
```js
assert.strictEqual(digitFibonacci(5), 21);
```
`digitFibonacci(10)`应该返回45。
```js
assert.strictEqual(digitFibonacci(10), 45);
```
`digitFibonacci(15)`应该返回69。
```js
assert.strictEqual(digitFibonacci(15), 69);
```
`digitFibonacci(20)`应该返回93。
```js
assert.strictEqual(digitFibonacci(20), 93);
```
# --seed--
## --seed-contents--
```js
function digitFibonacci(n) {
return n;
}
digitFibonacci(20);
```
# --solutions--
```js
const digitFibonacci = (n) => {
const digits = (num) => {
return num.toString().length;
};
let f1 = 1;
let f2 = 1;
let index = 3;
while (true) {
let fn = f1 + f2;
if (digits(fn) === n) return index;
[f1, f2] = [f2, fn];
index++;
}
};
```