递归 递归指的是调用自己的函数 每个递归都有两个条件 base case : 终止条件 recursive case : 递归条件 所有的函数的调用都遵循 call stack 递归语法的清晰是以内存为代价的 通过递归求阶乘 def fact(n): if n == 1: #base case(终止条件) return 1 else: return n * fact(n-1)#recursive case print(fact(5)) ## 120

Continue reading

Author's picture

Jixing Liu

Reading And Writing

Data Scientist

China