Exercise

# Approximate Pi with recursion

The number \(\pi\) can be computed by the following formula: $$ \pi = 4\sum_{k=0}^{\infty}\frac{(-1)^k}{2k+1}=4\left(\frac{1}{1}-\frac{1}{3}+\frac{1}{5}-\frac{1}{7}+\frac{1}{9}-…\right) $$ Your task is to write a recursive function to approximate \(\pi\) using the formula defined above (the approximation means that instead of infinity \(\infty\), the sequence considers only a certain amount of elements \(n\)).

Here are examples of \(\pi\) for some of the values of \(n\):

\(n=0 \rightarrow \pi = 4\)

\(n=1 \rightarrow \pi \approx 2.67\)

\(n=2 \rightarrow \pi \approx 3.47\)

Instructions 1/2

**undefined XP**

- Write a lambda expression calculating the \(k\)-th element in the series (without taking 4 into account).