Harmonic Number Calculator

Calculate the nth harmonic number Hₙ = 1 + 1/2 + 1/3 + ... + 1/n. Supports exact computation up to n = 1000 and asymptotic approximation for larger values.

980.2K uses Updated · 2026-05-06 Runs locally · zero upload
AD

How to Use Harmonic Number Calculator

The Harmonic Number Calculator computes Hₙ for any positive integer n you enter. Enter the value of n in the input field, and the calculator immediately shows the decimal result, the first few terms of the sum, and an asymptotic approximation using the natural logarithm.

  1. Enter n — Type any positive integer from 1 to 100,000.
  2. Review the Expansion — The Harmonic Number Calculator displays the first several terms (1 + 1/2 + 1/3 + …) so you can see how the sum builds.
  3. Check the Approximation — The asymptotic formula ln(n) + γ is shown alongside the exact result for comparison.

The input must be a positive integer. Decimal or negative values are not accepted.

Formula & Theory - Harmonic Number Calculator

The Harmonic Number Calculator uses this core formula or rule from the definition of the harmonic series:

Hₙ = Σ(k=1 to n) 1/k = 1 + 1/2 + 1/3 + ... + 1/n

Asymptotic:
Hₙ ≈ ln(n) + γ + 1/(2n) − 1/(12n²)

where γ ≈ 0.5772156649015329 (Euler-Mascheroni constant)
SymbolMeaning
Hₙnth harmonic number
nNumber of terms
ln(n)Natural logarithm of n
γEuler-Mascheroni constant ≈ 0.5772

The harmonic series diverges — Hₙ grows without bound as n → ∞ — but it does so extremely slowly (logarithmically). For example, H₁₀ ≈ 2.928, H₁₀₀ ≈ 5.187, H₁₀₀₀ ≈ 7.485, and H₁₀₀₀₀ ≈ 9.788.

Assumptions and Limits

This calculator requires n to be a positive integer. For n ≤ 1000, the exact sum is computed by iterating 1/k for each term. For n > 1000, the asymptotic expansion is used, which is accurate to at least 8 decimal places for all n ≥ 10.

Use Cases for Harmonic Number Calculator

The Harmonic Number Calculator is used across mathematics, computer science, and probability theory:

  • Series analysis — Understand how partial sums of the harmonic series grow and verify textbook limits.
  • Algorithm complexity — Harmonic numbers appear naturally in the average-case analysis of algorithms like QuickSort (expected comparisons ≈ n·Hₙ).
  • Probability problems — The coupon collector’s problem predicts the expected number of draws to collect all n coupons as n·Hₙ.
  • Combinatorics — Harmonic numbers arise in counting cycles in random permutations.
  • Calculus and sequences — Study the convergence behavior of p-series and partial sums in calculus courses.

The Harmonic Number Calculator removes tedious manual summation and lets you explore how Hₙ scales with n, making it a practical companion for both coursework and research.

Frequently asked questions about Harmonic Number Calculator

What is a harmonic number?

The nth harmonic number Hₙ is the sum of the reciprocals of the first n positive integers: Hₙ = 1 + 1/2 + 1/3 + ... + 1/n.

How accurate is the Harmonic Number Calculator for large n?

For n ≤ 1000 the calculator computes the exact floating-point sum. For n > 1000 it uses the asymptotic formula Hₙ ≈ ln(n) + γ + 1/(2n) − 1/(12n²), where γ ≈ 0.5772 is the Euler-Mascheroni constant. The error is less than 10⁻⁸ for n > 100.

What is the Euler-Mascheroni constant?

The Euler-Mascheroni constant γ ≈ 0.5772156649 is the limiting difference between the harmonic series and the natural logarithm: γ = lim(n→∞)(Hₙ − ln n).

Is my data stored?

No. All calculations happen in your browser; nothing is sent to a server.