Discuss / Python / 交作业:

交作业:

Topic source

明天过后.

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

写的和c似的。。。

def pi(N):
    odd =  itertools.count(1, 2)
    sum = 0
    count = 0
    for n in odd:
        sum += ((-1)**count)*4/n
        count += 1
        if count >= N:
            break
    return sum

  • 1

Reply