# 求阶乘 def factorial(n): return 1 if n <= 1 else n * factorial(n - 1) print(factorial(5)) # 求阶乘之和 def getSum(n): s = 0 for x in range(1, n + 1): s = s + factorial(x) return s print(getSum(5))
# 求阶乘 def factorial(n): return 1 if n <= 1 else n * factorial(n - 1) print(factorial(5)) # 求阶乘之和 def getSum(n): s = 0 for x in range(1, n + 1): s = s + factorial(x) return s print(getSum(5))