所以这是我的代码:
def f(n):
if n == 0:
return 1
else:
result = 1
for i in range(1,n+1):
result = result * i
return result
def a(n):
sum = 0
z = 0
for i in range(n+1):
sum += f(i)
print('{0:<4}! = {1:<4} no.multi. ={} sum of {}! = {} no.multi. = {}'.format(i,f(i),i,i,sum,z))
z = z + (i+1)
a(19)
我需要得到这个输出:
但相反,我得到了一种金字塔
我试图在括号内格式化,但我总是收到错误:“无法从手动字段规范切换到自动字段编号”提前谢谢
扬帆大鱼
相关分类