All pastes #1839708 Raw Edit

piCalc.py

public python v1 · immutable
#1839708 ·published 2010-03-14 17:39 UTC
rendered paste body
import mathfact = math.factorialdef calcPi(Iterations=100, verbose=True):    total = 0    for k in range(Iterations):        temp = (fact(6.*k) * (13591409. + 545140134. * k))        temp /= (fact(3.*k) * fact(k)**3. * 640320. ** (3.*k+(3./2.)))        total += temp        if verbose: print (total * 12)**(-1)    return (total * 12)**(-1)if __name__ == "__main__":    print "%f" % (calcPi(1, verbose=False))#Output#3.141593