1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/斐波那契数列 [fei-bo-na-qi-shu-lie-lcof].html
2022-03-29 12:43:11 +08:00

34 lines
805 B
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

<p>写一个函数,输入 <code>n</code> 求斐波那契Fibonacci数列的第 <code>n</code> 项(即 <code>F(N)</code>)。斐波那契数列的定义如下:</p>
<pre>
F(0) = 0,   F(1) = 1
F(N) = F(N - 1) + F(N - 2), 其中 N > 1.</pre>
<p>斐波那契数列由 0 和 1 开始,之后的斐波那契数就是由之前的两数相加而得出。</p>
<p>答案需要取模 1e9+71000000007如计算初始结果为1000000008请返回 1。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 2
<strong>输出:</strong>1
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>n = 5
<strong>输出:</strong>5
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 <= n <= 100</code></li>
</ul>