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