斐波那契数列迭代伪代码
时间: 2023-09-12 17:07:03 浏览: 116
python斐波那契数列第n项.docx
以下是斐波那契数列迭代伪代码:
```
function fibonacci(n)
if n == 0
return 0
else if n == 1
return 1
else
fibPrevPrev = 0
fibPrev = 1
fibCurrent = 0
for i from 2 to n
fibCurrent = fibPrev + fibPrevPrev
fibPrevPrev = fibPrev
fibPrev = fibCurrent
return fibCurrent
```
阅读全文