Harmonic Numbers Calculator

Compute the nth partial sum of the harmonic series and compare it with the logarithmic estimate.

Math and PercentUpdated 2026-11-202 min read
Harmonic Numbers Calculator
Harmonic number
...
Log approximation...
Difference...

What it does

The harmonic numbers are the partial sums of the harmonic series. The nth value is one plus one half plus one third, continuing through one over n. They appear in analysis, number theory, algorithm running times and many counting problems where a reciprocals sum shows up.

Although each added term becomes tiny, the total does not settle down. The harmonic series diverges, so the numbers grow without bound. They grow very slowly, however, roughly like the natural logarithm of n.

A useful approximation is the natural log of n plus Euler's constant, about 0.577216. The tool prints that estimate next to the exact sum so you can see how good it is. The difference between the two shrinks toward zero as n grows, albeit slowly.

For small n the exact sum is easy to write by hand. For larger n the tool adds the terms directly. The input is limited to one million so the loop finishes quickly, and the result is shown with six decimal places because the early terms matter at that scale.

Harmonic numbers connect to many other ideas. They give the expected number of records in a random sequence, appear in the analysis of quicksort and hash tables, and relate to the digamma function in more advanced work.

How to use

  1. Enter a positive whole number n.
  2. Read the exact sum of reciprocals up to n.
  3. Read the natural log plus Euler constant approximation.
  4. Compare the two values and read their difference.
  5. Try larger n to see the approximation improve.
  6. Remember that the series has no finite limit.

Formula

H_n = sum from k=1 to n of 1/k. Approximation: H_n is about ln(n) + gamma, with gamma about 0.5772156649.
H_n
The nth harmonic number.
n
A positive integer index.
k
The summation index from 1 to n.
gamma
Euler's constant, about 0.5772156649.

The tool sums the reciprocals directly, so the exact value is accurate to the displayed precision for all allowed n. The logarithm estimate uses Euler's constant and improves as n grows. The series diverges, so there is no limiting value even though the estimate grows slowly.

Worked example

Example: the tenth harmonic number

Default input: n = 10.

  1. Add the reciprocals: 1 + 1/2 + ... + 1/10.
  2. The exact sum is 2.928968.
  3. Natural log of 10 is 2.302585.
  4. Add Euler's constant: 2.302585 + 0.577216 = 2.879801.
  5. The difference is 2.928968 - 2.879801 = 0.049167.
  6. The tool shows 2.928968, 2.879801 and 0.049167.

Reference table

Harmonic numbers and their log estimates
nH_nln(n) + gamma
11.0000000.577216
102.9289682.879801
1005.1873785.182386
10007.4854717.484973

Limits

  • Accepts only positive whole numbers up to one million.
  • Uses a direct sum, which is simple rather than asymptotically optimised.
  • The log estimate ignores higher order correction terms.
  • Does not compute generalized harmonic numbers with other exponents.

Common mistakes

  • Entering zero or a negative index.
  • Expecting the series to converge to a finite value.
  • Confusing Euler's constant with the base of the natural logarithm.
  • Rounding the sum too early when adding many small terms.
  • Using log base ten instead of the natural logarithm in the estimate.

Try it yourself

Quick checks. Answers sit tucked under each question.

What is H1 and how does it compare with the estimate?

H1 is 1.000000. The estimate is 0.577216, so the difference is 0.422784.

Does the difference grow or shrink with n?

It shrinks toward zero. The exact sum and the log plus gamma estimate get closer as n increases.

What happens if n is entered as a decimal?

The tool returns the error Enter a whole number n between 1 and 1,000,000, because the index must be an integer.

Questions

What is a harmonic number?

The sum of the reciprocals of the first n positive integers.

Does the harmonic series converge?

No. The partial sums grow without bound, though very slowly.

What is Euler's constant?

The limiting difference between the harmonic number and the natural log of n, about 0.577216.

Where do harmonic numbers appear?

In algorithm analysis, record statistics, number theory and many sums involving reciprocals.

Why use log plus gamma?

It is the leading term of the asymptotic expansion and is already close for moderate n.

Can I compute very large n?

The tool stops at one million to keep the direct sum fast. Larger n would use an asymptotic expansion instead.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.