首页 > 代码库 > 递归函数打印斐波那契数列

递归函数打印斐波那契数列

def f(n, arg1=0, arg2=1, arg3=1):
    while n >0:
        arg3 = arg1 + arg2
        i = arg3 - arg2
        print(i)
        arg1, arg2 = arg2, arg1 + arg2
        n -= 1
        return f(n, arg1, arg2)

f(1)

  

递归函数打印斐波那契数列