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