用Python编写程序求1!+2!+……+7!
import mathprint(sum(math.factorial(i) for i in range(1, 8))) fact = 1
fsum = fact
for n in range(2, 8):
fact *= n
fsum += fact
print(fsum) a = 1
b = a
for n in range(2, 8):
a = a * n
b = b + a
print(b)
冬雪雪冬 发表于 2021-12-20 17:50
谢谢啊
页:
[1]