代码:
pi = 0
N = 100
for k in range(N):
pi += 1/pow(16,k)*(4/(8*k+1)-2/(8*k+4)-1/(8*k+5)-1/(8*k+6))
print("据公式求得圆周率:{}".format(pi))
print('3040')
运行截图:
2022-01-03 18:06:33
代码:
pi = 0
N = 100
for k in range(N):
pi += 1/pow(16,k)*(4/(8*k+1)-2/(8*k+4)-1/(8*k+5)-1/(8*k+6))
print("据公式求得圆周率:{}".format(pi))
print('3040')
运行截图: