python算法之打印N的阶乘实例讲解
程序员文章站
2022-05-16 20:33:40
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)
上一篇: 中国电信赵慧玲:云计算与智能管道