Advertisement
vencinachev

LeinitzPI

Jan 5th, 2021
1,137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. static double CalcPI()
  2.         {
  3.             double pi = 1;
  4.             for (int i = 3, cnt = 0; i < 100000; i += 2, cnt++)
  5.             {
  6.                 if (cnt % 2 == 0)
  7.                 {
  8.                     pi -= (double)1 / i;
  9.                 }
  10.                 else
  11.                 {
  12.                     pi += (double)1 / i;
  13.                 }
  14.             }
  15.             pi *= 4;
  16.             return pi;
  17.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement