用while循环求编写求s=1+(1+2)+(1+2+3)+...+n)的值
时间: 2023-05-31 19:02:46 浏览: 83
Java程序约瑟夫环
5星 · 资源好评率100%
n = int(input("请输入n的值:"))
s = 0
i = 1
while(i <= n):
j = 1
temp = 1
while(j <= i):
temp *= j
j += 1
s += temp
i += 1
print("s的值为:", s)
阅读全文