1、手写
def Foo(x): if (x==1): return 1 else: return x*Foo(x-1) print(Foo(4))
2、系统库函数
math.factorial(4)
3、for循环
def foo(n): result = 1 for i in range(1,n+1): if i == 1: result = 1 else: result = i * result return result foo(4)
标签:foo,return,else,result,阶乘,Foo From: https://www.cnblogs.com/z977690557/p/16661717.html