首页 > TAG信息列表 > fibRecur
12_迭代和递归
求一个数的阶乘 # 迭代方法实现 def factIter(n): result = n for i in range(1, n): result *= i return result print(factIter(10)) # 递归方法实现 def funC(n): if n == 1: return 1 else: return n * funC(n-1) print(funC(112_迭代和递归
求一个数的阶乘 # 迭代方法实现 def factIter(n): result = n for i in range(1, n): result *= i return result print(factIter(10)) # 递归方法实现 def funC(n): if n == 1: return 1 else: return n * funC(n-1) print(funC(1