How does this code calculate pi with high precision?

Here is the code:

#include <stdio.h>

long f[2801];

int main()
{
    long i = 0, c = 2800, d = 0, e = 0, g = 0;
    for (i = 0; i < c; ++i)
        f[i] = 2000;
    for (;;) {
        d = 0; 
        g = c * 2;
        if (!g)
            break;
        i = c;
        for(;;) {
            d += f[i] * 10000;
            --g;
            f[i] = d % g;
            d /= g;
            --g;
            --i;
            if (!i) break;
            d *= i;
        }
        printf("%.4ld",e+d/10000);
        e = d % 10000;
        c -= 14;
    }
    return 0;
}

My question is: how does this code calculate pi with a high degree of decimal precision, and what is the mathematical formula that it uses?

+4
source share
1 answer

This is a formatted copy of the PI program written by Dick T. Winter of the CWI Institute in Holland. Originally written in intricate form, in two or three lines, there are several variations of Dik and others that display a different number of PI places (for example, 800, 15,000, etc.) Based on the evaluation of the mathematical series.

, " ", . Google Dik Winter " ". :

Pi C .

Pi ,

+2

Source: https://habr.com/ru/post/1656428/


All Articles