Spaces:
Running
on
Zero
Running
on
Zero
File size: 312 Bytes
c705142 c7e3756 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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))
|