Harmonic Number Calculator

Compute the nth harmonic number H(n), partial sums, approximations using the Euler-Mascheroni constant, and generalized harmonic numbers.

H(10)
2.928968
Sum of 1/k from k=1 to 10
ln(n) + γ Approximation
2.879801
ln(10) + 0.577216
Approximation Error
0.049167
Difference |Hₙ − (ln n + γ)|
Better Approximation
2.929801
ln(n) + γ + 1/(2n) — error: 0.000833
Euler-Mascheroni γ
0.5772156649
The limit of Hₙ − ln(n) as n → ∞
Growth Rate
O(ln n) ≈ 2.3026
Harmonic numbers grow logarithmically

Convergence: Hₙ vs ln(n) + γ

H(1)
1.0000
H(2)
1.5000
H(3)
1.8333
H(4)
2.0833
H(5)
2.2833
H(6)
2.4500
H(7)
2.5929
H(8)
2.7179
H(9)
2.8290
H(10)
2.9290
Blue bars: Hₙ — Red dashed: ln(n) + γ approximation

Partial Sums Table

n1/nHₙln(n)+γError
11.0000001.0000000.5772160.422784
20.5000001.5000001.2703630.229637
30.3333331.8333331.6758280.157505
40.2500002.0833331.9635100.119823
50.2000002.2833332.1866540.096680
60.1666672.4500002.3689750.081025
70.1428572.5928572.5231260.069731
80.1250002.7178572.6566570.061200
90.1111112.8289682.7744400.054528
100.1000002.9289682.8798010.049167
Planning notes, formulas, and examples

About the Harmonic Number Calculator

The harmonic numbers Hₙ = 1 + 1/2 + 1/3 + … + 1/n are among the most important constants in mathematics. Despite each additional term being smaller, the harmonic series diverges — it grows without bound, though only logarithmically. The nth harmonic number is closely approximated by ln(n) + γ, where γ ≈ 0.5772 is the Euler-Mascheroni constant.

This calculator computes exact harmonic numbers up to H(10000), shows how closely the logarithmic approximation matches, and visualizes the convergence behavior. It also supports generalized harmonic numbers H(n, m) = Σ 1/kᵐ, which connect to the Riemann zeta function ζ(m) as n → ∞.

Harmonic numbers appear throughout mathematics, computer science, and physics. In algorithm analysis, the expected number of comparisons in a random search is related to Hₙ. The coupon collector's problem — the expected number of random draws to collect all n types — equals n · Hₙ. In physics, harmonic numbers arise in quantum mechanics and the study of Stirling numbers. Understanding their growth rate is fundamental to discrete mathematics and analysis of algorithms.

When This Page Helps

Computing harmonic numbers by summing 1 + 1/2 + 1/3 + … + 1/n becomes increasingly tedious as n grows, and floating-point rounding accumulates over thousands of terms. This calculator computes exact partial sums up to H(10,000), compares them against the ln(n) + γ approximation and the improved ln(n) + γ + 1/(2n) approximation, and shows the convergence behavior visually. It also supports generalized harmonic numbers H(n,m) connecting to the Riemann zeta function, making it a versatile tool for number theory and algorithm analysis.

How to Use the Inputs

  1. Enter the value of n to compute H(n).
  2. Choose single value, range, or generalized mode.
  3. For generalized harmonic numbers, specify the power m.
  4. Adjust decimal places for desired precision.
  5. Use presets for common values like H(100) or H(1000).
  6. Compare the computed value with the ln(n) + γ approximation in the output.
  7. Check the convergence chart and table for detailed analysis.
Formula used
Hₙ = 1 + 1/2 + 1/3 + … + 1/n Hₙ ≈ ln(n) + γ + 1/(2n) γ ≈ 0.5772156649 (Euler-Mascheroni constant)

Example Calculation

Result: H(10) ≈ 2.928968

H(10) = 1 + 1/2 + 1/3 + … + 1/10 = 7381/2520 ≈ 2.928968. The approximation ln(10) + γ ≈ 2.879 is close but slightly under.

Tips & Best Practices

  • The harmonic series diverges — no finite limit exists — but it does so very slowly.
  • H(n) exceeds 10 only when n ≈ 12367.
  • The Euler-Mascheroni constant γ is the limit of Hₙ − ln(n) as n → ∞.
  • Generalized harmonic numbers with m = 2 give partial sums of the Basel series (π²/6).
  • The difference 1/(2n) correction halves the approximation error.

Why the Harmonic Series Diverges

Despite each successive term 1/n approaching zero, the harmonic series 1 + 1/2 + 1/3 + … diverges. The classic proof groups terms: 1/3+1/4 > 2·(1/4) = 1/2, 1/5+1/6+1/7+1/8 > 4·(1/8) = 1/2, and so on, producing infinitely many half-units. This logarithmic divergence means Hₙ ~ ln(n) + γ grows without bound but excruciatingly slowly — you need about 10^43 terms just to reach Hₙ = 100. Understanding this divergence is a cornerstone of analysis and a gateway to convergence tests for other series.

The Euler-Mascheroni Constant

The Euler-Mascheroni constant γ ≈ 0.5772156649 is defined as lim(Hₙ − ln n) as n → ∞. Despite its importance — it appears in the Gamma function, Laplace transforms, and analytic number theory — it remains unknown whether γ is rational or irrational (most mathematicians conjecture it is irrational). The constant connects discrete summation (Hₙ) to continuous integration (ln n), bridging combinatorics and calculus. The correction term 1/(2n) roughly halves the approximation error, and further terms in the asymptotic expansion (the Euler–Maclaurin formula) yield even better fits.

Harmonic Numbers in Computer Science

Harmonic numbers appear throughout algorithm analysis. The expected number of comparisons in a random search of n items is Hₙ. Quicksort's average-case complexity involves 2n·Hₙ comparisons. The coupon collector problem — how many random draws to collect all n coupons — has expected value n·Hₙ. Hash table collision analysis, skip list performance, and even the secretary problem (optimal stopping) involve harmonic numbers. Recognizing when Hₙ ≈ ln(n) appears allows quick runtime and probability estimates in practice.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • Hₙ is the sum 1 + 1/2 + 1/3 + … + 1/n. It grows logarithmically and appears throughout math and computer science.