bk-sandbox / 00-sandbox.py
bkoz's picture
updated
c705142
raw
history blame
311 Bytes
def fibonacci(n: int) -> list:
"""
:param n:
:return:
"""
if n == 0:
return []
elif n == 1:
return [0]
elif n == 2:
return [0, 1]
else:
a, b = 0, 1
res = [0, 1]
for i in range(2, n):
c = a + b
res.append(c)
a, b = b, c
return res
if __name__ == '__main__':
print(fibonacci(10))