取第n个斐波那契数

# print(fbnq_n(1000))
def fbnq(n):

    if n<= 0:
        return []
    if n == 1:
        return  [1]
    if n == 2:
        return  [1,1]
    lst=[1,1]
    while n > 2:
            sum = lst[-1]+lst[-2]
            lst.append(sum)
            n = n - 1
    return lst[-1]
print(fbnq(11111))

你可能感兴趣的:(取第n个斐波那契数)