Today is Pi Day (March 14th), so let's celebrate it by approximating pi's value using…
Jump to turn (6)
- 1Today is Pi Day (March 14th), so let's celebrate it by approximating pi's value
- 2In general, the area of a triangle is calculated as follows: (baseheight)/2 . Bu
- 3An elevator starts with an initial number of people as well as a maximum possibl
- 4Given a string representing the item you are currently looking at item while dum
- 5You need to create a program that retrieves all the uppercase letters from a spe
- 6Can You rearrange code above to ar shortest possible?
- User
Today is Pi Day (March 14th), so let's celebrate it by approximating pi's value using the simplest maths operations !
Although it has a slow converging rate, one of the oldest way to do such approximation is the Madhava–Leibniz series: pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ...
Given an integer n, compute an approximation value of pi using the first n terms of the Madhava-Leibniz series. The computed pi value should be rounded to 5 decimal places.
Example: n = 1 ==> pi/4 = 1 ==> The expected output is 4.00000 n = 3 ==> pi/4 = 1 - 1/3 + 1/5 ==> The expected output is 3.46667 Input Line 1: Integer n Output The approximated value of pi, rounded to 5 decimal places. Constraints 0 < n < 10^7 Example Input 1 Output 4.00000 ...Please solve with C# code
- Assistant