Skip to content

Instantly share code, notes, and snippets.

@moolex
Created January 12, 2013 13:43
Show Gist options
  • Save moolex/4518133 to your computer and use it in GitHub Desktop.
Save moolex/4518133 to your computer and use it in GitHub Desktop.
一段神奇的代码,仅仅4行就可以算出Pi的800位
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 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment