G
Gerald Britton
Surely on track for the *slowest* way to compute pi in Python (or any
language for that matter):
math.sqrt( sum( pow(k,-2) for k in xrange(sys.maxint,0,-1) ) * 6. )
Based on the Riemann zeta function:
The sum of
1/k^2 for k = 1:infinity
converges to pi^2 / 6
Depending on your horsepower and the size of sys.maxint on your
machine, this may take a few *days* to run.
Note: The sum in the Python expression above runs in reverse to
minimize rounding errors.
language for that matter):
math.sqrt( sum( pow(k,-2) for k in xrange(sys.maxint,0,-1) ) * 6. )
Based on the Riemann zeta function:
The sum of
1/k^2 for k = 1:infinity
converges to pi^2 / 6
Depending on your horsepower and the size of sys.maxint on your
machine, this may take a few *days* to run.
Note: The sum in the Python expression above runs in reverse to
minimize rounding errors.