更新第三次实验第二题

This commit is contained in:
Luthics 2022-11-06 14:08:29 +08:00
parent e0c587e7bf
commit 5558047439
1 changed files with 1 additions and 4 deletions

View File

@ -3,9 +3,6 @@ a = int(n.split('-')[1]) # 暴力取出小数位数和精度
i = 1
s = 0
while (1 / (2 * i - 1) >= 10**(-a)): # 精度要求作为条件
if (i % 2 == 0):
s -= 1 / (2 * i - 1)
else:
s += 1 / (2 * i - 1)
s += (-1)**(i % 2 + 1) / (2 * i - 1)
i += 1
print(("{:." + str(a) + "f}").format(s * 4))