~/algor $ cat problems/for-leybnis-qatori
Leibniz series
Easy
1000 ms
64 MB
30%
A positive integer $n$ is given. Approximate the number $\pi$ with the Leibniz series: multiply the sum of the first $n$ terms in the parentheses by $4$:
$$S = 4 * \left(1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \dots + \frac{(-1)^{n-1}}{2 * n - 1}\right)$$
Input
One positive integer $n$.
Output
One number — $S$, with exactly 6 digits after the decimal point (for example, 4.000000).
Note
$1 \le n \le 10^{6}$
Examples
Input #1
1
Output #1
4.000000
Input #2
3
Output #2
3.466667