Discuss / Python / pi

在路上Ce

#1 Created at ... [Delete] [Delete and Lock User]
def pi(N):
    odd_list = itertools.count(1, 2)
    pre_n_list = itertools.takewhile(lambda x: x <= 2 * N - 1, odd_list)
    sum_list = [(2 - i % 4)/i * 4 for i in pre_n_list ]
    return sum(sum_list)

  • 1

Reply