阶乘
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)
当你的才华撑不起你的野心时,你需要静下心来学习。
浙公网安备 33010602011771号