Harmonic Number Calculator
Compute Hn = 1 + 1/2 + 1/3 + … + 1/n exactly, and compare it against the ln n + γ asymptotic estimate. Not the harmonic mean — this is the partial sum.
Harmonic Number Calculator
Background.
The nth harmonic number, written Hn, is what you get by adding the reciprocals of the whole numbers up to n: Hn = 1 + 1/2 + 1/3 + … + 1/n. This calculator returns that sum, alongside the classical estimate ln n + γ + 1/(2n) − 1/(12n²) and the gap between them, so you can see for yourself how quickly the approximation becomes indistinguishable from the real thing.
One thing to settle before you read the number: this is not the harmonic mean. The harmonic mean takes a dataset you supply and returns a central value, n divided by the sum of the reciprocals of your values. A harmonic number takes a single index and returns a running total over the first n positive integers. The two share a reciprocal and nothing else. There is exactly one line connecting them worth knowing — the harmonic mean of the numbers 1, 2, …, n equals n ⁄ Hn — and if it is an average you want, the harmonic mean calculator is the page you need.
Harmonic numbers matter because the harmonic series diverges, but does it maddeningly slowly. Adding terms forever gets you to infinity; adding twelve thousand of them barely gets you past 10. That behaviour is why Hn turns up in the average-case cost of quicksort, in the coupon-collector problem, and in the analysis of self-balancing structures — anywhere a cost accumulates as 1/k over k steps. The growth rate is captured exactly by the constant that appears in the estimate above: γ, the Euler–Mascheroni constant, which NIST's Digital Library of Mathematical Functions defines as the limit of Hn − ln n and gives as 0.57721566490153286060.
Because the sum has no closed form, this page tells you plainly which method produced your answer. Up to n = 25,000 every term is added one at a time at full decimal precision. Above that the three-term expansion is used instead, because summing a hundred thousand terms takes long enough to stall a browser, and by then the expansion's first dropped term is around 10⁻²⁰ — twenty orders of magnitude smaller than the last digit shown. The method line sits beside the result, not inside a collapsed FAQ.
What is harmonic number calculator?
A harmonic number Hn is the partial sum of the harmonic series: Hn = Σ from k = 1 to n of 1/k, so H1 = 1, H2 = 1.5, H3 ≈ 1.8333, H10 = 7381/2520 ≈ 2.92897. Wolfram MathWorld gives this definition and the asymptotic expansion Hn ~ ln n + γ + 1/(2n) − (1/12)n⁻² + (1/120)n⁻⁴ − … as well as the analytic identity Hn = γ + ψ₀(n+1) relating harmonic numbers to the digamma function. NIST's DLMF states the same identity as ψ(n+1) = Σ 1/k − γ at equation 5.4.14. The series itself diverges — its partial sums grow without bound — but only logarithmically, which is why Hn is small even for very large n. Harmonic numbers are defined only at whole-number n; the natural extension to fractional arguments is the digamma function, which this page does not cover.
How to use this calculator.
- Enter how many terms you want to add. The calculator sums 1 + 1/2 + 1/3 up to 1/n.
- Read Hn as the main result, then compare it against the ln n + γ estimate shown beside it.
- Check the method line to see whether the value was summed exactly or approximated — the calculator switches at n = 25,000 and tells you which branch ran.
- If what you actually wanted was the harmonic mean of your own list of numbers, use the harmonic mean calculator instead — it answers a different question.
The formula.
There is no closed form for Hn, so the exact value has to be summed term by term. This calculator does that at full decimal precision, with no rounding during accumulation and a single rounding to 10 decimal places at the end. For n = 10 the arithmetic is small enough to check by hand: put every term over 2520, the least common multiple of 1 through 10, giving numerators 2520, 1260, 840, 630, 504, 420, 360, 315, 280 and 252, which total 7381 — so H10 = 7381/2520 = 2.9289682540. The estimate beside it comes from the Euler–Maclaurin expansion, ln n + γ + 1/(2n) − 1/(12n²), truncated after the 1/(12n²) term. At n = 10 that gives 2.9289674246, which falls 8.294 × 10⁻⁷ short of the exact value — and the first term the truncation dropped, +1/(120n⁴) = 1/1,200,000 = 8.333 × 10⁻⁷, accounts for essentially all of that gap, which is a useful reassurance that both the expansion and its implementation are right. The constant γ is entered as exactly the twenty significant digits NIST's DLMF prints at equation 5.2.3 and no more; none are invented. Above n = 25,000 the expansion replaces the exact sum, because adding a hundred thousand reciprocals is too slow to do on every keystroke while the expansion's truncation error at that point is roughly 2 × 10⁻²⁰. In that branch the estimate is the answer, so the exact-minus-estimate output reads 0 by construction, and the method line beside the result says so rather than leaving you to infer it.
A worked example.
Ask for ten terms. The calculator adds 1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8 + 1/9 + 1/10 and the harmonic number output reads 2.928968254 — which is exactly 7381/2520, as you can confirm by putting every term over 2520 and adding the numerators 2520 + 1260 + 840 + 630 + 504 + 420 + 360 + 315 + 280 + 252 = 7381. The ln n output is 2.302585093, and the estimate output adds γ and the two correction terms to reach 2.9289674246. The exact-minus-estimate output is therefore 0.0000008294 — the estimate is short by less than a millionth after only ten terms, and that shortfall is almost exactly the size of the first term the expansion leaves out, 1/(120 × 10⁴) = 0.00000083. The method line confirms that all ten terms were summed exactly rather than estimated.
Frequently asked questions.
Is a harmonic number the same as a harmonic mean?
Does the harmonic series diverge?
What is γ, the constant in the estimate?
Why does the calculator change method above 25,000 terms?
Can I get Hn for a fractional n?
References& sources.
- [1]Wolfram MathWorld, 'Harmonic Number' — eq. 1 defines Hn = Σ_(k=1)^n 1/k; eq. 2 gives Hn = γ + ψ₀(n+1); eq. 4 gives the asymptotic expansion ln n + γ + 1/(2n) − (1/12)n⁻² + (1/120)n⁻⁴ − (1/252)n⁻⁶ + …. Retrieved 2026-07-29; open access.
- [2]NIST Digital Library of Mathematical Functions, §5.2(ii) 'Euler's Constant', equation 5.2.3 — 'γ = lim(n→∞)(1 + 1/2 + 1/3 + ⋯ + 1/n − ln n) = 0.57721 56649 01532 86060…'. The digits used by this calculator are exactly these and no more. Retrieved 2026-07-29; open access.
- [3]NIST Digital Library of Mathematical Functions, §5.4(ii) 'Psi Function', equation 5.4.14 — 'ψ(n+1) = Σ_(k=1)^n 1/k − γ', the digamma identity quoted in the FAQ. An independent, structurally different statement of the same object. Retrieved 2026-07-29; open access.
- [4]OpenStax (Rice University), Calculus Volume 2, §5.3 'The Divergence and Integral Tests' — the integral-test proof that the harmonic series diverges despite its terms tending to zero. Retrieved 2026-07-29; open access.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 977 calculators remain free
- No billing is enabled