mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 18:03:07 +02:00
26 lines
436 B
C++
Executable File
26 lines
436 B
C++
Executable File
#include <math.h>
|
|
#include <iostream>
|
|
#include <iomanip>
|
|
|
|
const unsigned long long int ITERATIONS = 10000;
|
|
|
|
long double getPi()
|
|
{
|
|
long double pi = 4;
|
|
bool negative = 1;
|
|
for(unsigned int i = 3; i < ITERATIONS; i += 2)
|
|
{
|
|
if(negative) pi -= 4.0 / i;
|
|
else pi += 4.0 / i;
|
|
negative = !negative;
|
|
}
|
|
std::cout << std::setprecision(2000) << pi << std::endl;
|
|
return pi;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
getPi();
|
|
return 0;
|
|
}
|