using System;
class Program
{
static void Main()
{
// Get PI from methods shown here
double d = PI();
Console.WriteLine("{0:N20}",
d);
// Get PI from the .NET Math class constant
double d2 = Math.PI;
Console.WriteLine("{0:N20}",
d2);
}
static double PI()
{
// Returns PI
return 2 * F(1);
}
static double F(int i)
{
// Receives the call number
if (i > 60)
{
// Stop after 60 calls
return i;
}
else
{
// Return the running total with the new fraction added
return 1 + (i / (1 + (2.0 * i))) * F(i + 1);
}
}
}