Harmonic Number Calculator — H(n)
Calculate the nth harmonic number H(n) — the sum of the first n reciprocals 1 + 1/2 + … + 1/n — along with its asymptotic approximation using the Euler–Mascheroni constant.
Exact sum: 1 + 1/2 + 1/3 + … + 1/n
How does this calculator work?
H(n) = 1 + 1/2 + 1/3 + … + 1/n grows like ln(n) + 0.5772… (the Euler–Mascheroni constant). For n=10: H(10) ≈ 2.9290. For n=100: H(100) ≈ 5.1874. The series diverges but very slowly — it first exceeds 10 only around n ≈ 12 367.
Formula
How this is calculated
The nth harmonic number H(n) is defined as the finite sum of unit fractions from 1 to 1/n: H(n) = 1 + 1/2 + 1/3 + ⋯ + 1/n. This calculator computes it by direct summation (accurate for any integer n up to 100 000). The terms 1/k decrease rapidly at first but slow down, so the partial sums grow without bound — the series diverges — but extremely slowly: H(n) doubles in size roughly every time n is squared.
For large n, direct summation becomes slow, so mathematicians use the asymptotic expansion H(n) ≈ ln(n) + γ + 1/(2n) − 1/(12n²) + …, where γ ≈ 0.5772… is the Euler–Mascheroni constant, defined as the limiting difference between H(n) and ln(n). This approximation is remarkably accurate: for n = 100 the error is less than 10⁻⁸. The calculator shows both the exact sum and the approximation so you can see how well they agree.
Harmonic numbers appear in the analysis of algorithms (quicksort and hash tables), coupon-collector problems ("how many packs until you complete the set?"), special values of the Riemann zeta function, and the generalised harmonic numbers used in analytic number theory.
Frequently asked questions
No. The harmonic series Σ(1/k) from k = 1 to ∞ diverges — its sum grows without bound. The growth is very slow (roughly ln n), so for practical n the partial sums look nearly stationary, but they are provably unbounded. The classic proof groups terms: 1/2 ≥ 1/2; 1/3 + 1/4 > 1/2; 1/5 + 1/6 + 1/7 + 1/8 > 1/2; and so on, forming infinitely many groups each exceeding 1/2.
γ ≈ 0.5772156649… is the limit of H(n) − ln(n) as n → ∞. It measures the persistent gap between the harmonic partial sums and the natural logarithm. It appears throughout number theory and analysis; whether it is rational or irrational is an unsolved problem.
In the average-case analysis of quicksort, the expected number of comparisons is ≈ 2n ln n = 2n × H(n) / log base. In the coupon-collector problem, the expected number of draws to collect all n distinct coupons is n × H(n). Hash table expected search lengths also involve H(n).
Also known as
TG we-Calculate Editorial Team. (2026). Harmonic Number Calculator — H(n) [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/harmonic-number-calculator
TG we-Calculate Editorial Team. "Harmonic Number Calculator — H(n)." TG we-Calculate. 2026. https://we-calculate.com/calculator/harmonic-number-calculator.
TG we-Calculate Editorial Team, "Harmonic Number Calculator — H(n)," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/harmonic-number-calculator
@misc{wecalculate_harmonic_number_calculator, title = {Harmonic Number Calculator — H(n)}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/harmonic-number-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
