递归

作者: 蓝剑狼 | 来源:发表于2018-10-26 18:50 被阅读7次
    
    def count_down(i):
        print(i)
        if i <=0:
            return "倒计时到此结束"
        else:
            count_down(i-1)
    
    print(count_down(10))
    
    def fact(x):
        if x==1:
            return 1
        else:
            return x * fact(x-1)
    
    print(fact(6))
    
    def test_depth(x):
        x +=1
        print("第%d次运行"%x)
        test_depth(x)
    
    fact(0)

    相关文章

      网友评论

          本文标题:递归

          本文链接:https://www.haomeiwen.com/subject/skultqtx.html