迭代 利用for循环&range() def factorial(number): product = 1 for i in range(number): product = product * (i+1) return product 递归 利用if-else条件判断&调用自身 def factorial(number): if number <= 1: return 1 else: return number*factorial(number-1) 总结 迭代递归for循环if-else条件判断range调用自身