Advertisement
BowserFlash13

pi

Jun 27th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5. long double pi(int n) {
  6.     long double sum = 0.0;
  7.     int sign = 1;
  8.     for (int i = 0; i < n; ++i) {
  9.         sum += sign / (2.0*i + 1.0);
  10.         sign *= -1;
  11.     }
  12.     return 4.0*sum;
  13. }
  14. int main()
  15. {
  16.     long double n=1, a=0;
  17.     while (true) {
  18.         cout <<setprecision(1000)<< pi(n)<<endl;
  19.         n++;
  20.         a++;
  21.         /*
  22.         if (a == 5000) {
  23.         system("pause");
  24.         a = 0;
  25.         }*/
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement