piCalc.py
public python v1 · immutableimport 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