1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-04 15:01:40 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2023-04-23 22:41:08 +08:00
parent 6465d37d92
commit 6de82df1ca
146 changed files with 25201 additions and 12876 deletions

View File

@@ -0,0 +1,37 @@
<p>请你编写一个生成器函数,并返回一个可以生成 <strong>斐波那契数列</strong> 的生成器对象。</p>
<p><strong>斐波那契数列</strong> 的递推公式为 <code>X<sub>n</sub>&nbsp;= X<sub>n-1</sub>&nbsp;+ X<sub>n-2</sub></code></p>
<p>这个数列的前几个数字是 <code>0, 1, 1, 2, 3, 5, 8, 13</code>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>callCount = 5
<b>输出:</b>[0,1,1,2,3]
<strong>解释:</strong>
const gen = fibGenerator();
gen.next().value; // 0
gen.next().value; // 1
gen.next().value; // 1
gen.next().value; // 2
gen.next().value; // 3
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>callCount = 0
<strong>输出:</strong>[]
<b>解释:</b>gen.next() 永远不会被调用,所以什么也不会输出
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 &lt;= callCount &lt;= 50</code></li>
</ul>