Skip to content

Instantly share code, notes, and snippets.

@zhangys-lucky
Created August 19, 2015 00:40
Show Gist options
  • Save zhangys-lucky/868796ca36f97d451c28 to your computer and use it in GitHub Desktop.
Save zhangys-lucky/868796ca36f97d451c28 to your computer and use it in GitHub Desktop.
print PI using C
#include <stdio.h>
long a=10000,b,c=2800,d,e,f[2801],g;
int 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);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment