根据泰勒级数关系式:pi / 4 = 1 - 1/3 + 1/5 - 1/7 + ..... + (-1)^k (1 / (2k+1) ) + ....
求圆周率的值,当最后一项的值小于给定的阈值时结束
threshold = eval(input()) pi4 = k = 0 f = 1 while abs(1 / (2 * k + 1)) >= threshold: pi4 = pi4 + f * 1 / (2 * k + 1) k = k + 1 f = -f print("{:.6f}".format(pi4*4))