[Tutor] How to calculate pi with this formula?

Bill Mill bill.mill at gmail.com
Thu Oct 28 19:29:38 CEST 2004


Dick,

Recursively:

mpi(n, d, lim):
    if d >= lim: return 1 + (n/d)
    return 1 + (n/d) * mpi(n+1, d+2, lim)

>>> 2 * mpi(1., 3., 1000)       #note that 1 and/or 3 need to be floats
3.1415926535897931

Peace
Bill Mill
bill.mill at gmail.com

On Thu, 28 Oct 2004 09:44:09 -0700, Dick Moores <rdm at rcblue.com> wrote:
> Is it possible to calculate almost-pi/2 using the (24) formula on
> <http://mathworld.wolfram.com/PiFormulas.html> without using (23)?
> 
> If it's possible, how about a hint? Recursion?
> 
> Thanks, tutors.
> 
> Dick Moores
> rdm at rcblue.com
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list