how to generate pi in c

Jim Davis jjdavis at email.arizona.edu
Fri Nov 5 16:58:11 UTC 2010


On Fri, Nov 5, 2010 at 9:40 AM, Arthur Bela <jozsi.avadkan at gmail.com> wrote:
> Does anyone has a "generate-pi.c" source code?

a[52514],b,c=52514,d,e,f=1e4,g,h;main(){for(;b=c-=14;h=printf("%04d",
e+d/f))for(e=d%=f;g=--b*2;d/=g)d=d*b+f*(h?a[b]:f/5),a[b]=d%--g;}

...though that's only good for the first 15,000 digits. You probably
need to be more specific about what you're looking for; the literature
on generating digits of pi is pretty extensive.  Cf.
http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/spigot.pdf


More information about the users mailing list