斐波那契数列的递归算法

def fibo(x, l=[]):
    l.append(x)
    if x== 2:
        l.remove(x)
        return 1,1
    else:
        a, b = fibo(x-1)
        l.remove(x)
        if len(l) == 0:
            return a+b
        return b, a+b

猜你喜欢

转载自www.cnblogs.com/dabenniao/p/11084818.html