Python计算π值-麦克劳林公式
环境准备
Python版本: Python 3.6.4
IDE: Pycharm 2019.2.3
麦克劳林公式:
实现代码
# coding=utf-8
my_pi = 2
i = 1000
while i > 0:
my_pi = my_pi * i / (2 * i + 1) + 2
i -= 1
print(my_pi)
注:i值越大,求出的π值越精确
THE END
麦克劳林公式:
# coding=utf-8
my_pi = 2
i = 1000
while i > 0:
my_pi = my_pi * i / (2 * i + 1) + 2
i -= 1
print(my_pi)
注:i值越大,求出的π值越精确