We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b57fa56 commit 64841b1Copy full SHA for 64841b1
Math/509.md
@@ -0,0 +1,33 @@
1
+## 509 Fibonacci Number
2
+
3
+#### Description
4
5
+[link](https://leetcode.com/problems/fibonacci-number/)
6
7
+---
8
9
+#### Solution
10
11
+- See Code
12
13
14
15
+#### Code
16
17
+<!-- O(n) -->
18
19
+```python
20
+class Solution:
21
+ def fib(self, N: int) -> int:
22
+ if N == 0:
23
+ return 0
24
+ if N == 1:
25
+ return 1
26
+ x_0 = 0
27
+ x_1 = 1
28
+ for i in range(2, N + 1):
29
+ x_2 = x_0 + x_1
30
+ x_0 = x_1
31
+ x_1 = x_2
32
+ return x_2
33
+```
0 commit comments