两种方式实现求n的阶乘

# 通过递归实现求n的阶乘
def my_test(n):
    if n is 0:
        return 1
    else:
        return n*my_test(n-1)

print(my_test(5))

>> 120

# 通过普通循环实现求n的阶乘
def my_test2(n):
    result = n
    for i in range(1,n):
        result *= i
    return result

print(my_test2(5))

>> 120

标题名称:两种方式实现求n的阶乘
标题链接:http://myzitong.com/article/ijpjgj.html