def pi(N): return sum([(-1) ** (n - 1) * 4 / (n * 2 - 1) for n in itertools.takewhile(lambda i: i <= N, itertools.count(1))])
计算快,耗时短!!
受教。。
牛逼牛逼,非常简洁!
Sign in to make a reply
CloudSurf