The mathematical constant π (Greek pi) is commonly used in mathematics. It is also known as Archimedes' constant.
π is an irrational number, which means that its value cannot be expressed exactly as a fraction m/n, where m and n are integers. Consequently, its decimal representation never ends or repeats.
This post shows a program that calculates an estimation of the π constant. This approach is based on the attached file Pi as an integral.
The advantage of this approach is that it calculates the π with a summation, it means that the task can be easily divided among computers so that the final result, that is the π estimation, will be the sum of the result of each computer.
The following program is a naive implementation of the method shown in Pi as an integral.
#include <stdio.h>
pi *= (long double)2.0;
Note that the greater is n the more precise will be the estimation.
For this example the value calculated for π was 3.141592653589788512... .
by rcor

Posts >