But the Programs link is even more interesing, especially the Tiny Programs page. Ok, I have a minor gripe: this webpage has frames.... the direct URL is http://numbers.computation.free.fr/Constants/TinyPrograms/tinycodes.html.
Gosh, the following short C code computes digits for π
int a=10000,b,c=8400,d,e,f[8401],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);
}
I have no clue how this code work... I would expect a program to sum up some known series for π... what's this 8400 and -14?? No clue.
I tested it and it works. I am just AMAZED.
1 comment:
Maybe a practical question regarding your other post is: how often do we need pi in real life? (given now we have this stunning algorithm for computing its value extremely precisely). I can't remember the last time I need pi outside of class. Calculus is more useful in this regard :P
Post a Comment