python中定义一个函数做为参数,为一个整数的N, 调用函数求得 1+2!+3!+...+n! 的和。(2!为2的阶乘)

解法一:单次循环 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:
相关文章
相关标签/搜索