#B2070. Alternating Harmonic Series
Alternating Harmonic Series
Alternating Harmonic Series
Calculate the alternating harmonic series defined by the formula: \( S_n = \frac{1}{1} - \frac{1}{2} + \frac{1}{3} - \frac{1}{4} + \cdots + (-1)^{n-1}\times\frac{1}{n} \).
Given an integer n
, compute S_n
.
inputFormat
An integer n
is given on a single line. (For example: 1 ≤ n ≤ 106)
outputFormat
Output the computed value of S_n
rounded to 6 decimal places.
sample
1
1.000000