Python, LintCode, 366. 斐波纳契数列

class Solution:
    """
    @param n: an integer
    @return: an ineger f(n)
    """
    def fibonacci(self, n):
        # write your code here
        res = [0, 1]
        for i in range(2, n):
            res.append(res[i-1]+res[i-2])
        return res[n-1]

猜你喜欢

转载自blog.csdn.net/u010342040/article/details/80067975