January 29th, 2010, 12:03 PM
Computing Pi from the infinite series
I am brand spanking new to C# and am not only wondering about the syntax, but also the logic of how to do this, my professor just threw us to the wolves with this problem and we haven't gone over any of the syntax or anything, I am not a math major so I'm not familiar with the infinite series, nothing explained! And yet it's due on Monday.
The problem is that she wants a C# console program which computes Pi from an infinite series
Pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ....
"Ask the user the number of decimal places you should compute Pi to and display the number of terms (counting the initial 4) that it takes to compute Pi to that many places. The formula can be used to determine if your approximation is close enough
Math.Abs(Math.PI - approxPi) < (0.5 * Math.Pow(0.1, decimalPlaces))
Please enter the number of decimal places to compute to: 2
It requires 200 terms to approximate Pi to 2 decimal places. "
Please help I am completely lost, I need help with logic and help how to program this in C#.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!