利用一维数组实现Fibonacci数列前10项
时间: 2024-01-01 21:44:51 浏览: 75
打印Fibonacii数列前10个元素
Sure, I can help you with that. Here are the first 10 terms of the Fibonacci sequence using a one-dimensional array in Python:
```
fib = [0, 1]
for i in range(2, 10):
fib.append(fib[i-1] + fib[i-2])
print(fib)
```
Output: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
阅读全文