def pi(N): ns = itertools.takewhile(lambda n : n <= 2 N - 1, itertools.count(1, 2)) return sum(map(lambda x: -4 / x (-1)**((x + 1) / 2), ns))
Sign in to make a reply
冲浪小白兔
def pi(N): ns = itertools.takewhile(lambda n : n <= 2 N - 1, itertools.count(1, 2)) return sum(map(lambda x: -4 / x (-1)**((x + 1) / 2), ns))