#K9726. K-th Harmonic Number Calculation
K-th Harmonic Number Calculation
K-th Harmonic Number Calculation
Given a positive integer k
, calculate the k-th harmonic number defined by the formula:
\(H_k = \sum_{i=1}^{k} \frac{1}{i}\)
The result should be rounded to 4 decimal places.
Note: The input will be provided via standard input, and the output should be printed to standard output. Ensure that your solution handles large inputs efficiently.
inputFormat
The input consists of a single line containing an integer k
(1 ≤ k ≤ 107 or as specified by the problem constraints) representing the position of the harmonic number to compute.
outputFormat
Output the k-th harmonic number rounded to 4 decimal places.
## sample1
1.0000
</p>