递归实现斐波那契

def fun(i):

    if i == 0:

        return 0

    elif i == 1:

        return 1

    else:

        return fun(i-2) + fei(i-1)

if __name__ == '__main__':

    for i in range(10):

        print(fun(i),end=" ")

 

 

posted @ 2020-08-12 08:12  Python代  阅读(58)  评论(0编辑  收藏  举报