Monte Carlo integration, simple example

We end this first part with a discussion of a brute force Monte Carlo program which integrates $$ \begin{equation*} \int_0^1dx\frac{4}{1+x^2} = \pi, \end{equation*} $$ where the input is the desired number of Monte Carlo samples.