Files
LeetCode-Book/python/sfo_10i_fibonacci_numbers_s1.py
krahets 649c652c59 [Update]
1. Update topic names of Pyhon file.
2. Replace the binary tree printer with a more clear one.
3. Update README.
2021-12-29 21:04:09 +08:00

23 lines
423 B
Python

'''
File: sfo_10-i_fibonacci_numbers_s1.py
Created Time: 2021-12-09
Author: Krahets (krahets@163.com)
'''
from include import *
# ===== Solution Code =====
class Solution:
def fib(self, n: int) -> int:
a, b = 0, 1
for _ in range(n):
a, b = b, (a + b) % 1000000007
return a
# ======= Test Case =======
n = 5
# ====== Driver Code ======
slt = Solution()
res = slt.fib(n)
print(res)