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

Re: [FWP] algorithm to calculate pi



Perl lover wrote:
> 
> looking for a short one in Perl. saw one in C:
> 
> long a=10000, b,c=2800,d,e,f[2801],g;
> 
> int main(int argc, char* argv[]) {
>      for (;b-c;)f[b++]=a/5;
>      for (;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)
>      for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);
>      return 0;
> }
> 
> gets pi's first 280 digits..

remember seeing a simple alg a few years ago that computes
the successive digits of pi...  in binary. (i.e., pi base 2).
whole equation involved something like 3 terms, including
the 'i'.

/. given we can compute pi base 2, anyone have a nice, quick
base-2-> base-10 converter?

-- 
 Steven Lembark                                   2930 W. Palmer St.
                                                 Chicago, IL  60647
 lembark@wrkhors.com                                   800-762-1582

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