📜  如何递归函数 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:26.252000             🧑  作者: Mango

代码示例1
#Simply recursive function that counts from 0 to 10
def count(n): #function named count
    
    if n <= 10: #base case.This is to put a limit to the amount of recursions
        print(n)
        count(n+1) # this is a "recursive call" to the function count
      
count(0) # this is where the function is first called.