Discuss / Python / PI

CloudSurf

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

有为若是

#2 Created at ... [Delete] [Delete and Lock User]

计算快,耗时短!!

受教。。

牛逼牛逼,非常简洁!


  • 1

Reply