題目描述
大家都知道斐波那契數(shù)列,現(xiàn)在要求輸入一個(gè)整數(shù)n无切,請(qǐng)你輸出斐波那契數(shù)列的第n項(xiàng)(從0開(kāi)始,第0項(xiàng)為0)丐枉。
n<=39
# -*- coding:utf-8 -*-
class Solution:
def Fibonacci(self, n):
# write code here
temp = [0,1]
while len(temp) <= n:
temp.append(temp[-1] + temp[-2])
return temp[n]