testsAndMisc-archive/CPP/miscelanious/Pi/main.cpp
Krzysztof kuhy Rudnicki 5966821bad fix: correct shebang and executable permissions
- Add +x to Python scripts with shebangs (3 files)
- Remove -x from non-script files like .cpp, .txt, makefile (23 files)
- Move shebang to first line in C/imageViewer/lint.sh
2025-11-30 13:42:16 +01:00

26 lines
411 B
C++

#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;
}