python求1到20階乘的和?
def factorial(n):
if n == 1:
return 1
else:
return n*factorial(n-1)
def SumFactorial(m):
if m ==1 :
return factorial(1)
else:
return factorial(m) + SumFactorial(m-1)
m = 20
print(SumFactorial(m))
python求1到20階乘的和?
def factorial(n):
if n == 1:
return 1
else:
return n*factorial(n-1)
def SumFactorial(m):
if m ==1 :
return factorial(1)
else:
return factorial(m) + SumFactorial(m-1)
m = 20
print(SumFactorial(m))