mirror of
https://github.com/ptitSeb/box64.git
synced 2024-11-23 22:49:43 +00:00
28dc8e6751
Closes: #895
36 lines
620 B
C
36 lines
620 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
//from https://crypto.stanford.edu/pbc/notes/pi/code.html
|
|
// 800 first decimals of PI
|
|
|
|
int main() {
|
|
int r[2800 + 1];
|
|
int i, k;
|
|
int b, d;
|
|
int c = 0;
|
|
|
|
for (i = 0; i < 2800; i++) {
|
|
r[i] = 2000;
|
|
}
|
|
|
|
for (k = 2800; k > 0; k -= 14) {
|
|
d = 0;
|
|
|
|
i = k;
|
|
for (;;) {
|
|
d += r[i] * 10000;
|
|
b = 2 * i - 1;
|
|
|
|
r[i] = d % b;
|
|
d /= b;
|
|
i--;
|
|
if (i == 0) break;
|
|
d *= i;
|
|
}
|
|
printf("%.4d", c + d / 10000);
|
|
c = d % 10000;
|
|
}
|
|
|
|
return 0;
|
|
} |