calculate pi using the series
pi /4 =1-1/3+1/5-1/7+1/9- ... and so on.
output the estimate of pi after computing 100,1000,10,000 and 100,000 terms of the series.
1
Expert's answer
2013-01-14T09:17:50-0500
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace Calculate_pi { class Program { static void Main(string[] args) {
Console.WriteLine("Pi after computing 100 = " + computePi(100)); Console.WriteLine("Pi after computing 1000 = " + computePi(1000)); Console.WriteLine("Pi after computing 10000 = " + computePi(10000)); Console.WriteLine("Pi after computing 100000 = " + computePi(100000)); Console.ReadLine(); }
Comments
Leave a comment