python算法之打印N的阶乘实例讲解
程序员文章站
2022-09-03 08:01:57
N的阶乘
n! = n * f(n-1)
1! = 1, 2! = 1 * 2, 3! = 1 * 2 * 3
def test(n):
if n == 1:...
N的阶乘
n! = n * f(n-1)
1! = 1, 2! = 1 * 2, 3! = 1 * 2 * 3
def test(n): if n == 1: return 1 else: return n * test(n - 1)