04.简单的递归函数

#函数在内部调用自身本身,这个函数就是递归函数。
def fect(n):
    if n<1:
        return 0
    if n==1:
        return 1
    return n*fect(n-1)
#递归
print(fect(3))

C:\Users\Administrator.000\AppData\Local\Programs\Python\Python36\python.exe E:/python/04递归函数.py
6


Process finished with exit code 0

猜你喜欢

转载自blog.csdn.net/qq_34908148/article/details/80377022