Prerequisites: Basic course part I
According to Gottfried and Leibniz, it is possible to calculate pi using the following formula: $$\frac{\pi}{4} = 1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - ...$$ Let the user choose the number of terms as input. Then print what the approximate value of pi will be. In the formula above, five terms are shown. Don't forget the 4!
Feel free to experiment with your program. How many terms do you need to get two decimal places of accuracy on pi? Five decimals? $$\pi = 3.1415926535...$$ Above, pi is shown with the first ten correct decimals.
-- Output from your program will be here --