Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/for-leybnis-qatori

Leibniz series

Easy 1000 ms 64 MB 30%
Share

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)$$

Computing pi with the Leibniz series

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

Sign in to submit a solution

Signing up is free and takes a minute.