Skip to main content
math

Harmonic Number Calculator

Calculate the nth harmonic number H(n) = 1 + 1/2 + 1/3 + … + 1/n, a fundamental quantity in number theory and analysis.

By Christopher FloiedPublished Updated

Range: 1 – 100,000. Whole numbers only

Compute H(n) = Σ 1/k for k=1 to n

Results

H(n)

2.928968254

Approximation (ln n + γ)

2.8798007579

How to Use This Calculator

1

Enter your input values

Fill in all required input fields for the Harmonic Number Calculator. Follow the units and input format printed next to each field. Where a unit selector is available, choose the units that match your data.

2

Review your inputs

Double-check that all values are correct and match the units or format shown for each field. Incorrect units are the most common source of calculation errors and can produce results that are off by factors of 2, 10, or more.

3

Read the results

The Harmonic Number Calculator computes the output in your browser and displays the results, with units clearly labeled, as soon as they are ready — no data sent to a server.

4

Explore parameter sensitivity

Try adjusting individual input values to see how the output changes. This is a quick and effective way to develop intuition about how different parameters influence the result and to identify which inputs have the largest effect.

When to Use This Calculator

  • •Use the Harmonic Number Calculator when you need a quick mathematical result without writing out all the steps manually, saving time on repetitive calculations.
  • •Use it to verify hand calculations on tests or assignments and catch arithmetic mistakes.
  • •Use it when teaching or explaining mathematical concepts to others, demonstrating how changing inputs affects the result.
  • •Use it to explore the behavior of mathematical functions across a range of inputs.

Related Calculators

About Harmonic Number Calculator

The harmonic numbers are the partial sums of the harmonic series: H(n) = 1 + 1/2 + 1/3 + … + 1/n. Despite their simple definition, harmonic numbers are remarkably important in mathematics and computer science. They appear in the analysis of sorting algorithms (quicksort's expected comparisons involve H(n)), the coupon collector's problem, random permutations, and the distribution of prime numbers. The harmonic series itself diverges — H(n) grows without bound as n increases — but it does so extremely slowly, growing as ln(n) + γ where γ ≈ 0.5772 is the Euler–Mascheroni constant. This slow divergence means that even H(10^100) is only about 230.8. Harmonic numbers connect to the Riemann zeta function (ζ(1) diverges), the digamma function (ψ(n+1) = H(n) − γ), and Stirling numbers. This calculator computes exact harmonic numbers alongside the logarithmic approximation so you can see how accurate the asymptotic formula is.

The Math Behind It

H(n) satisfies the recurrence H(n) = H(n−1) + 1/n with H(1) = 1. The asymptotic expansion is H(n) = ln(n) + γ + 1/(2n) − 1/(12n²) + 1/(120n⁴) − … where γ is the Euler–Mascheroni constant. Generalized harmonic numbers are H(n,m) = Σ 1/k^m for k=1 to n; for m > 1 these converge as n → ∞ to the Riemann zeta function ζ(m). The alternating harmonic series 1 − 1/2 + 1/3 − 1/4 + … converges to ln(2). Harmonic numbers appear in the expected number of coupons needed to complete a collection (n × H(n)) and in the analysis of the quicksort algorithm. The integral representation is H(n) = ∫₀¹ (1 − xⁿ)/(1 − x) dx. No harmonic number beyond H(1) = 1 is an integer.

Formula Reference

Harmonic Number

H(n) = Σ (1/k) for k = 1 to n

Variables: n = upper limit

Asymptotic Approximation

H(n) ≈ ln(n) + γ + 1/(2n)

Variables: γ ≈ 0.5772 (Euler–Mascheroni constant)

Worked Examples

Example 1: Compute H(5)

Find H(5) = 1 + 1/2 + 1/3 + 1/4 + 1/5.

Step 1:H(5) = 1 + 0.5 + 0.3333… + 0.25 + 0.2
Step 2:H(5) = 60/60 + 30/60 + 20/60 + 15/60 + 12/60
Step 3:H(5) = 137/60

H(5) = 137/60 ≈ 2.2833

Common Mistakes & Tips

  • !Assuming the harmonic series converges — it diverges, albeit very slowly.
  • !Using the approximation ln(n) + γ for small n where the error is significant.
  • !Confusing harmonic numbers H(n) with harmonic means.

Related Concepts

Used in These Calculators

Calculators that build on or apply the concepts from this page:

Frequently Asked Questions

Does the harmonic series converge?

No. The harmonic series diverges, meaning H(n) → ∞ as n → ∞, but it grows very slowly — approximately as ln(n) + 0.5772.

What is the Euler–Mascheroni constant?

γ ≈ 0.5772156649 is defined as the limit of H(n) − ln(n) as n → ∞. It is not known whether γ is rational or irrational.

Add the live Harmonic Number Calculator to your site. Free to embed, with a link back to MegaCalc.