aboutsummaryrefslogtreecommitdiff
path: root/C++/LeibnizPI.cpp
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-09-15 15:53:59 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-09-15 15:53:59 +0300
commit4b88d354f628182beeb25ad76f57e8a616ff30c1 (patch)
treef9419e4c72ecd2ffbf41c743031bc7e9cc4e2840 /C++/LeibnizPI.cpp
parent65c04eaad8fbcce98c3c11054ee52b5277c82402 (diff)
downloadalgorithms-4b88d354f628182beeb25ad76f57e8a616ff30c1.tar
algorithms-4b88d354f628182beeb25ad76f57e8a616ff30c1.tar.gz
algorithms-4b88d354f628182beeb25ad76f57e8a616ff30c1.zip
Renamed C++ folder to accomodate C files
Diffstat (limited to 'C++/LeibnizPI.cpp')
-rw-r--r--C++/LeibnizPI.cpp26
1 files changed, 0 insertions, 26 deletions
diff --git a/C++/LeibnizPI.cpp b/C++/LeibnizPI.cpp
deleted file mode 100644
index 2243f61..0000000
--- a/C++/LeibnizPI.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <iostream>
-
-using namespace std;
-
-int main()
-{
- cout << "n = ";
- unsigned int n = 1;
- cin >> n;
- long double pid4 = 1;
-
- for(unsigned int i = 0, dvsr = 3; i < n; i++, dvsr += 2) {
- pid4 += ((i % 2) ? 1.0 : -1.0) / dvsr;
- }
-
- cout.precision(64);
- cout << endl << pid4 * 4.0 << endl;
-
- return 0;
-}
-
-/* This is a quick implementation of of the Leibniz formula for PI
- * https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80
- *
- * Fun fact: you need around 100 million iterations for 7 correct decimal places
- */