§ Текст программы

110 DIM Z(255)
211 LET D=0
312 LET P=0
420 LET M=250
521 FOR I=1 TO M
630 LET Z(I)=20
731 NEXT I
832 PRINT "PI=";
940 LET E=D-100*INT(D/100)
1041 LET D=0
1142 FOR I=1 TO M
1250 LET J=M-I
1351 LET D=D+D*J+Z(J+1)*100
1460 LET A=J+J+1
1561 LET Z(J+1)=D-A*INT(D/A)
1662 LET D=INT(D/A)
1770 NEXT I
1871 LET M=M-6
1972 LET E=E+INT(D/100)
2080 PRINT INT(E/10);
2181 IF P=0 THEN PRINT ".";
2282 LET P=1
2390 PRINT E-10*INT(E/10);
2491 IF M>10 THEN GO TO 40

§ Иллюстрация программы


§ Реализация на С

1#include <stdio.h>
2
3int main() {
4
5    int z[256];
6    int a, j, d = 0, p = 0, m = 250, e;
7    for (int i = 1; i <= m; i++) z[i]=20;
8    printf("PI=");
9
10    do {
11
12        e = d % 100;
13        d = 0;
14        for (int i = 1; i <= m; i++) {
15            j = m - i;
16            d += (d*j + z[j+1]*100);
17            a = 2*j+1;
18            z[j+1]= d % a;
19            d /= a;
20        }
21
22        m -= 6;
23        e += (d / 100);
24        printf("%d", e/10);
25        if (p == 0) { printf("."); p = 1; }
26        printf("%d", e % 10);
27
28    } while (e > 10);
29
30    printf("\nPI=3.141592653589793238462643383279502\n");
31    return 0;
32}