how to generate pi in c

JD jd1008 at gmail.com
Fri Nov 5 16:55:48 UTC 2010


On 11/05/2010 09:40 AM, Arthur Bela wrote:
> Does anyone has a "generate-pi.c" source code?
>
> Thanks.. :D :\
I do not have that specific file, but this might help you

Calculate pi to 800 digits in 160 characters of code. Written by Dik T. 
Winter at CWI.

     int a=10000,b,c=2800,d,e,f[2801],g;main(){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);}

See
http://www.di-mgt.com.au/cprog.html


More information about the users mailing list