Harmonic Number Calculator

Enter a whole number n to find the nth harmonic number Hₙ = 1 + 1/2 + 1/3 + … + 1/n, exactly and as a decimal.

Updated

Enter to calculate Esc to clear

Harmonic Number Calculator

Our Harmonic Number Calculator finds the nth harmonic number Hₙ, the sum of the reciprocals 1 + 1/2 + 1/3 + … + 1/n. Type any whole number n and the result appears straight away to 10 decimal places, together with the exact fraction (for n up to 2,000), the approximation ln n + γ and the gap between the two. It works for any n up to 10¹⁵, where the sum would take far too long to add term by term.

Quick answer

The nth harmonic number is the sum of the reciprocals of the first n whole numbers. For example, H₄ = 1 + 1/2 + 1/3 + 1/4 = 25/12 ≈ 2.0833. Enter any whole number n above and the calculator shows Hₙ instantly.

  • Formula: Hₙ = 1 + 1/2 + 1/3 + … + 1/n
  • Key values: H₁ = 1, H₂ = 1.5, H₁₀ = 7381/2520 ≈ 2.9289682540, H₁₀₀ ≈ 5.1873775176
  • Approximation: Hₙ ≈ ln n + γ, where γ ≈ 0.5772156649
  • Growth: Hₙ grows without limit, but slowly; it passes 10 only at n = 12,367

What Is a Harmonic Number?

The nth harmonic number Hₙ adds up the reciprocals of the whole numbers from 1 to n:

Hₙ = 1 + 1/2 + 1/3 + … + 1/n
= Σ 1/k, for k = 1 to n

Each harmonic number is the previous one plus one more term, so Hₙ = Hₙ₋₁ + 1/n. By convention H₀ = 0, because a sum with no terms is 0. The infinite sum 1 + 1/2 + 1/3 + … is called the harmonic series, and Hₙ is its nth partial sum.

The name comes from music: a string divided into halves, thirds and quarters gives the harmonics (overtones) of its note, and those lengths are 1/2, 1/3, 1/4 of the whole.

Table of Harmonic Numbers

nFractionDecimal
111
23/21.5
311/61.8333333333
425/122.0833333333
5137/602.2833333333
649/202.45
7363/1402.5928571429
8761/2802.7178571429
97129/25202.8289682540
107381/25202.9289682540
1286021/277203.1032106782
2055835135/
15519504
3.5977396571

The fractions get long quickly: H₁₀₀₀ written as a fraction has a 434-digit numerator. Decimals are rounded to 10 places, the same as the calculator.

Why the Harmonic Series Never Stops Growing

The terms 1/n shrink towards 0, yet their sum has no limit: the harmonic series diverges. The classic proof (Nicole Oresme, about 1350) groups the terms so each group is at least 1/2:

1 + 1/2 + (1/3 + 1/4)
+ (1/5 + … + 1/8) + …

> 1 + 1/2 + 1/2 + 1/2 + …

Adding infinitely many halves gives no finite total, so Hₙ passes every number eventually. It just does so very slowly:

  • Hₙ first passes 2 at n = 4, 3 at n = 11, 4 at n = 31 and 5 at n = 83.
  • It needs n = 12,367 terms to pass 10.
  • Even after 10¹⁵ terms (a thousand trillion), Hₙ is only about 35.116.

The graph shows Hₙ for n = 1 to 20 (dots) next to the curve ln n + γ. The dots climb more slowly each step but never level off.

Graph of the harmonic numbers H₁ = 1 up to H₂₀ ≈ 3.598 as dots, rising more slowly at each step, just above the curve y = ln n + γ 1 5 10 15 20 0 1 2 3 4 Hₙ ln n + γ H₂₀ ≈ 3.598 n

The ln n + γ Approximation

For large n, adding every term is slow. Harmonic numbers stay close to the natural logarithm plus a constant:

Hₙ ≈ ln n + γ

γ ≈ 0.5772156649
(Euler-Mascheroni constant)

Hₙ is always a little above ln n + γ, and the gap is close to 1/(2n), so it shrinks as n grows:

nHₙHₙ − (ln n + γ)
102.92896825400.0491674961
1005.18737751760.0049916667
1,0007.48547086060.0004999167
10⁶14.39272672295 × 10⁻⁷
10⁹21.30048150235 × 10⁻¹⁰

Adding more correction terms makes the formula far more accurate. This is the version the calculator uses above n = 2,000:

Hₙ ≈ ln n + γ + 1/(2n)
− 1/(12n²) + 1/(120n⁴)

Two simple bounds also hold for every n ≥ 1: ln(n + 1) < Hₙ ≤ 1 + ln n.

Properties of Harmonic Numbers

  • Recurrence: Hₙ = Hₙ₋₁ + 1/n, starting from H₀ = 0.
  • Never whole: H₁ = 1 is the only harmonic number from H₁ on that is a whole number. For n ≥ 2, Hₙ always has an even denominator.
  • Sum of harmonic numbers: H₁ + H₂ + … + Hₙ = (n + 1)Hₙ − n. For n = 4 that is 5 × 25/12 − 4 = 77/12.
  • Digamma link: Hₙ = ψ(n + 1) + γ, which extends harmonic numbers to non-whole n.
  • Slow growth: doubling n adds about ln 2 ≈ 0.693 to Hₙ.

Worked Examples

Find H₄. Put every term over the common denominator 12:

H₄ = 1 + 1/2 + 1/3 + 1/4
= 12/12 + 6/12 + 4/12 + 3/12
= 25/12 ≈ 2.0833333333

Find H₁₀. Using the denominator 2520 (the smallest number divisible by 1 to 10) gives H₁₀ = 7381/2520 ≈ 2.9289682540. The approximation ln 10 + γ ≈ 2.8798007579 is 0.049 too low, close to 1/(2 × 10) = 0.05.

Find H₁₀₀₀ without adding 1,000 terms.

ln 1000 + γ ≈ 7.4849709439
+ 1/2000 = 0.0005
≈ 7.4854709

The exact value is 7.4854708606, so one correction term already gives 7 correct digits.

Where Harmonic Numbers Appear

  • Coupon collector problem: collecting all n different coupons, picked at random, takes n × Hₙ tries on average. Rolling every face of a die takes 6 × H₆ = 14.7 rolls on average.
  • Quicksort: sorting n items in random order takes 2(n + 1)Hₙ − 4n comparisons on average, which is about 1.39 n log₂ n.
  • Stacking blocks: n identical blocks of length 1, one per level, can overhang a table edge by up to Hₙ ÷ 2. With 4 blocks the top block sticks out by 25/24, more than its whole length.
  • Number theory: harmonic numbers are linked to the Riemann zeta function, and Hₙ ≈ ln n is why the average number of divisors of a number near n is about ln n.
  • Records: in a random sequence of n values, the expected number of new highs (records) is Hₙ.

Harmonic Numbers in Excel and Code

ToolH₁₀
Excel 365 / Google Sheets=SUMPRODUCT(1/SEQUENCE(10))
Pythonsum(1 / k for k in range(1, 11))
Python (exact)sum(Fraction(1, k) for k in range(1, 11))
JavaScriptlet h = 0; for (let k = 1; k <= 10; k++) h += 1 / k;

Floating-point sums give 2.9289682539682538. Python's fractions.Fraction gives the exact 7381/2520. For huge n, use ln n + γ + 1/(2n) instead of a loop, or scipy.special.digamma(n + 1) + numpy.euler_gamma.

Common Mistakes

  • Thinking the series converges. The terms go to 0, but the sum does not settle; that alone never proves convergence.
  • Confusing it with a geometric series. 1 + 1/2 + 1/4 + 1/8 + … converges to 2; 1 + 1/2 + 1/3 + 1/4 + … does not.
  • Leaving out the first term. The sum starts with 1/1 = 1.
  • Adding the denominators. 1/2 + 1/3 is 5/6, not 2/5.
  • Mixing up the harmonic mean. The harmonic mean of 1 to n is n ÷ Hₙ, not Hₙ itself.

Key Terms

Reciprocal
1 divided by a number; the reciprocal of 4 is 1/4.
Hₙ
The nth harmonic number, 1 + 1/2 + … + 1/n.
Series
The sum of the terms of a sequence.
Diverge
Grow without limit instead of settling on a value.
γ
The Euler-Mascheroni constant, about 0.5772156649.
ln n
The natural logarithm of n, to base e.

How to Use the Harmonic Number Calculator

  1. Enter the number of terms. Type a whole number n from 0 up to 10¹⁵ (1,000,000,000,000,000). This is how many reciprocals 1, 1/2, 1/3, … are added together.
  2. Read the result. The harmonic number Hₙ appears as you type, to 10 decimal places. The table below it shows the sum, the exact fraction for n up to 2,000, the approximation ln n + γ and the gap between Hₙ and that approximation.
  3. Copy or start again. Press Copy to copy Hₙ, or Clear or Esc to start again. Negative numbers and decimals get a short message explaining why they do not work.

Example: enter 10 and the result is 2.9289682540. The table shows the fraction 7381/2520, ln 10 + γ ≈ 2.8798007579 and the gap 0.0491674961.

Who Can Use This Calculator?

Students and TeachersSeries, sequences and divergence proofs
ProgrammersAverage running times of sorting and hashing
Probability LearnersCoupon collector and record problems
Puzzle FansBlock stacking and other harmonic puzzles

Frequently Asked Questions (FAQs)

What is a harmonic number?

The nth harmonic number Hₙ is the sum of the reciprocals of the first n whole numbers: Hₙ = 1 + 1/2 + 1/3 + … + 1/n. For example H₃ = 1 + 1/2 + 1/3 = 11/6 ≈ 1.8333.

What is the formula for the nth harmonic number?

Hₙ = Σ 1/k for k = 1 to n, or step by step Hₙ = Hₙ₋₁ + 1/n with H₀ = 0. There is no simple closed formula, but for large n, Hₙ ≈ ln n + γ + 1/(2n), where γ ≈ 0.5772156649.

What is H₁₀, the 10th harmonic number?

H₁₀ = 7381/2520 ≈ 2.9289682540. Other values: H₄ = 25/12 ≈ 2.0833, H₁₀₀ ≈ 5.1873775176 and H₁₀₀₀ ≈ 7.4854708606.

Does the harmonic series converge?

No. The harmonic series 1 + 1/2 + 1/3 + … diverges: its partial sums Hₙ grow without limit, even though each term gets smaller. Grouping the terms as 1 + 1/2 + (1/3 + 1/4) + (1/5 + … + 1/8) + … gives groups that are each at least 1/2, and infinitely many halves have no finite total.

How fast does the harmonic series grow?

Very slowly, like the natural logarithm. Hₙ passes 2 at n = 4, 5 at n = 83 and 10 only at n = 12,367. After 10¹⁵ terms it is still only about 35.116.

How accurate is the approximation ln n + γ?

Hₙ is always a little above ln n + γ, by about 1/(2n). For n = 10 the gap is 0.0492, for n = 1,000 it is 0.0005, and for n = 10⁶ it is 0.0000005. Adding 1/(2n) − 1/(12n²) makes the approximation accurate to many decimal places.

What is the Euler-Mascheroni constant γ?

γ ≈ 0.5772156649 is the limit of Hₙ − ln n as n goes to infinity. It appears throughout number theory and analysis. Nobody yet knows whether it is a rational or irrational number.

Is a harmonic number ever a whole number?

Only H₁ = 1 (and H₀ = 0). For every n ≥ 2 the fraction for Hₙ has an odd numerator and an even denominator, so it is never a whole number.

What is the largest n this calculator supports?

Any whole number up to 10¹⁵. Up to n = 2,000 it adds the exact fractions, so it can also show Hₙ as a fraction. Above that it uses the expansion ln n + γ + 1/(2n) − 1/(12n²) + 1/(120n⁴), which is accurate well beyond the 10 decimal places shown.

Is the Harmonic Number Calculator free?

Yes. It is completely free, needs no sign-up, and can be used as many times as you like.

Try our Harmonic Number Calculator to find Hₙ for any n, exactly or to 10 decimal places, instantly.