--- id: 5900f3851000cf542c50fe98 challengeType: 5 videoUrl: '' title: 问题25:1000位斐波纳契数 --- ## Description
Fibonacci序列由递归关系定义:
F n = F n-1 + F n-2 ,其中F 1 = 1且F 2 = 1。
因此,前12个学期将是:
F 1 = 1
F 2 = 1
F 3 = 2
F 4 = 3
F 5 = 5
F 6 = 8
F 7 = 13
F 8 = 21
F 9 = 34
F 10 = 55
F 11 = 89
F 12 = 144
第12个学期F 12是第一个包含三位数的术语。 Fibonacci序列中包含n个数字的第一项的索引是多少?
## Instructions
## Tests
```yml tests: - text: digitFibonacci(5)应该返回21。 testString: assert.strictEqual(digitFibonacci(5), 21); - text: digitFibonacci(10)应该返回45。 testString: assert.strictEqual(digitFibonacci(10), 45); - text: digitFibonacci(15)应该返回69。 testString: assert.strictEqual(digitFibonacci(15), 69); - text: digitFibonacci(20)应该返回93。 testString: assert.strictEqual(digitFibonacci(20), 93); ```
## Challenge Seed
```js function digitFibonacci(n) { // Good luck! return n; } digitFibonacci(20); ```
## Solution
```js // solution required ``` /section>