The Grerory-Leibnitz series1 approximates π using the alternate series

4×(1113+1517+19)

Assignment

Write a function gregory_leibnitz that takes an integer nN0 (int). The function must return the approximation for π obtained from the first n terms in the Grerory-Leibnitz series.

Example

>>> gregory_leibnitz(1)
4.0
>>> gregory_leibnitz(10)
3.0418396189294032
>>> gregory_leibnitz(100)
3.1315929035585537
>>> gregory_leibnitz(1000)
3.140592653839794