用python编程求多项式sn=1-3+5-7+9-11+……的前100项和
发布网友
发布时间:2022-04-26 21:54
我来回答
共3个回答
热心网友
时间:2023-11-07 14:14
he = 0
for n in range(0,100):
if (n % 2 == 0):
he += 2 * n +1
else:
he -= 2 * n + 1
print(he)
代码这样就差不多了
热心网友
时间:2023-11-07 14:14
t,a,r=0,1,0
while a<=100:
空if t==0:
空空r,t=r+a,1
空else:
空空r,t=r-a,0
空a+=2
print r
热心网友
时间:2023-11-07 14:15
sum = 0
for i in range(1,101):
if (i % 2 == 0):
sum -= 2 * i -1
else:
sum += 2 * i - 1
print(sum)
热心网友
时间:2023-11-07 14:14
he = 0
for n in range(0,100):
if (n % 2 == 0):
he += 2 * n +1
else:
he -= 2 * n + 1
print(he)
代码这样就差不多了
热心网友
时间:2023-11-07 14:14
t,a,r=0,1,0
while a<=100:
空if t==0:
空空r,t=r+a,1
空else:
空空r,t=r-a,0
空a+=2
print r
热心网友
时间:2023-11-07 14:15
sum = 0
for i in range(1,101):
if (i % 2 == 0):
sum -= 2 * i -1
else:
sum += 2 * i - 1
print(sum)