[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] algorithm to calculate pi



		       On Sun, 25 Jun 2000 22:31:02 EDT,
			      Rick Delaney wrote:

:> I can't promise 280 digits, but here's something shorter:
:> 
:> #!/usr/bin/perl -l
:> for(0..9999){$i=$_*8;$p+=(16**-$_)*(4/($i+1)-2/($i+4)-1/($i+5)-1/($i+6))}pri
:nt$p
:
:Well, if precision doesn't count then there's always
:
:    print 4*atan2 1,1;

:-)

Actually, I didn't mean that this series can't deliver 280 digits; it's
good for as many digits as you please.  I just mean that "print$p" won't
deliver 280.  (Incidentally, the neat thing about this particular way
of computing pi is that you can use it to get the nth hexadecimal digit
without first calculating all the first n-1 digits.)

Michael

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe