解法一:单次循环
def num(n): i=1 c=1 h=0 while i<=n: c*=i h+=c print(c) i+=1 print(h) num(n)
解法二:while双循环
def num(n): row=1 h=0 while row<=n: col=1 l=1 while col<=row: l*=col col+=1 h +=l print(h) row+=1 num(n)
解法一:单次循环
def num(n): i=1 c=1 h=0 while i<=n: c*=i h+=c print(c) i+=1 print(h) num(n)
解法二:while双循环
def num(n): row=1 h=0 while row<=n: col=1 l=1 while col<=row: l*=col col+=1 h +=l print(h) row+=1 num(n)