XJTU_Python/homework/1/t3.py

8 lines
283 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

n = int(input("请输入想要计算的 n "))
ans = 0 # 储存答案
to_mul = 1 # 计算阶乘的中间量,会储存 (n-1)!
for i in range(n):
to_mul *= (i+1)
ans += to_mul
print(ans)