Compute the nth harmonic number H(n), partial sums, approximations using the Euler-Mascheroni constant, and generalized harmonic numbers.
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.
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.
Hₙ = 1 + 1/2 + 1/3 + … + 1/n Hₙ ≈ ln(n) + γ + 1/(2n) γ ≈ 0.5772156649 (Euler-Mascheroni constant)
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.
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 γ ≈ 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 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.
Hₙ is the sum 1 + 1/2 + 1/3 + … + 1/n. It grows logarithmically and appears throughout math and computer science.
No — it diverges. But it grows extremely slowly: H(10¹⁰⁰) is only about 230.
γ ≈ 0.5772 is the limiting difference between Hₙ and ln(n). It's unknown whether γ is rational or irrational.
H(n, m) = Σ 1/kᵐ. When m > 1, it converges to the Riemann zeta function ζ(m) as n → ∞.
Analysis of quicksort (expected comparisons ≈ 2n·Hₙ), hash table performance, the coupon collector problem, and skip list analysis. Use this as a practical reminder before finalizing the result.
The error is approximately 1/(2n). Adding this correction—ln(n) + γ + 1/(2n)—improves accuracy significantly.