366. Fibonacci

2018-01-11  本文已影响0人  fdgump

[ http://www.lintcode.com/en/problem/fibonacci/ ]

# Python
class Solution:
    """
    @param: n: an integer
    @return: an ineger f(n)
    """
    def fibonacci(self, n):
        # write your code here
        a, b = 0, 1
        i = 0
        while i < n-1:
            a, b = b, a + b
            i += 1
        return a
上一篇 下一篇

猜你喜欢

热点阅读