Harmonic Sum
Submit solution
Points:
100
Time limit:
1.0s
Memory limit:
256M
Author:
Problem types
Allowed languages
Python
Given a positive integer \(n\), compute the harmonic sum
\(H(n) = 1 + \frac{1}{2} + \frac{1}{3} + \cdots + \frac{1}{n}\).
Input
One line containing \(n\).
The input satisfies:
- \(1 \le n \le 10^6\)
Output
Print \(H(n)\), rounded to exactly three digits after the decimal point.
Example
Input
2
Output
1.500
Explanation
H(2) = 1 + 1/2 = 1.5, printed with exactly three decimal places as 1.500.
Comments