Advertisement
GraionDilach

Pi

Oct 24th, 2011
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication10
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             double pi =1;
  13.             double a = 2, b = 1;
  14.             for (int i = 0; i < 100000; i++)
  15.             {
  16.                 double local = a / b;
  17.  
  18.                 if (i % 2 != 0)
  19.                 {
  20.                     a = a + 2;
  21.                 }
  22.                 else
  23.                 {
  24.                     b = b + 2;
  25.                 }
  26.  
  27.                 pi = pi * local;
  28.  
  29.             }
  30.             pi = pi * 2;
  31.             Console.WriteLine(pi);
  32.         }
  33.     }
  34. }
  35.  
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement