Harmonic Number Calculator

Enter the number of terms n (and, optionally, the order r) to get the harmonic number H_n = 1 + 1/2 + ... + 1/n, its exact fraction, and an asymptotic estimate.

Quick Facts

Harmonic number
H_n = 1 + 1/2 + 1/3 + ... + 1/n
The sum of the reciprocals of the first n positive integers.
Generalized order r
H_n(r) = sum of 1/k^r, k = 1 to n
r = 1 gives the standard harmonic number; r > 1 keeps the sum bounded as n grows.
Asymptotic estimate
H_n ≈ ln(n) + γ + 1/(2n)
γ ≈ 0.5772156649 is the Euler–Mascheroni constant.
Divergence
H_n → ∞ as n → ∞ (for r ≤ 1)
The classic harmonic series diverges, but only as slowly as ln(n).

Your Results

Calculated
Harmonic Number H(n,r)
-
Sum of 1/k^r for k = 1 to n
Exact Fraction
-
Fully reduced p/q, when practical to show
Asymptotic Behavior
-
Euler–Mascheroni estimate or convergence note
nth Term
-
Last term added: 1/n^r

Ready

Enter n (and optionally r), then press Calculate.

Formula and Method for the Harmonic Number

The nth harmonic number is the sum of the reciprocals of the first n positive integers: H_n = 1 + 1/2 + 1/3 + ... + 1/n, written compactly as H_n = Σ (1/k) for k = 1 to n. This calculator also supports the generalized harmonic number of order r, H_n(r) = Σ (1/k^r) for k = 1 to n, where the ordinary harmonic number is simply the r = 1 case. Generalized harmonic numbers are the finite partial sums whose limit, for r > 1, is the Riemann zeta function ζ(r).

How the calculation works

Enter the number of terms n and, optionally, the order r. The calculator adds 1/k^r for every integer k from 1 to n to get the decimal value, tracks the running sum as an exact reduced fraction using integer arithmetic (shown when the denominator stays small enough to be useful), and reports the classic Euler–Mascheroni asymptotic estimate H_n ≈ ln(n) + γ + 1/(2n) − 1/(12n²) when r = 1, where γ ≈ 0.5772156649 is the Euler–Mascheroni constant. For r ≠ 1, it instead reports whether the p-series converges (r > 1) or diverges (r ≤ 1) as n grows without bound.

Common mistakes

  • Confusing the harmonic number with the harmonic mean: the harmonic mean of a data set divides n by a sum of reciprocals; the harmonic number is simply that sum of reciprocals itself.
  • Assuming the harmonic series converges: H_n grows without bound as n increases — it just grows extremely slowly, roughly like ln(n).
  • Expecting an exact fraction for large n or non-integer r: the exact reduced fraction's denominator grows almost exponentially with n, so beyond a few hundred terms only the decimal value is practical to display.

Real-world applications

  • Computer science uses H_n in the average-case running time of algorithms such as quicksort and in hashing analysis.
  • Probability theory uses harmonic numbers to solve the coupon collector's problem: the expected number of draws needed to collect all n distinct items is about n × H_n.
  • Number theory and analysis use the generalized harmonic numbers H_n(r) as the finite partial sums that converge to the Riemann zeta function ζ(r) for r > 1.
  • Physics and engineering use harmonic sums in series expansions and in modeling resistor networks and other reciprocal-based systems.

Frequently Asked Questions

What is a harmonic number?
The nth harmonic number H_n is the sum of the reciprocals of the first n positive integers: H_n = 1 + 1/2 + 1/3 + ... + 1/n. For example, H_4 = 1 + 1/2 + 1/3 + 1/4 = 25/12 ≈ 2.0833.
What is a generalized harmonic number of order r?
The generalized harmonic number of order r is H_n(r) = the sum of 1/k^r for k = 1 to n. Setting r = 1 recovers the standard harmonic number. As n approaches infinity, the sum converges to the Riemann zeta function ζ(r) when r > 1, but diverges when r ≤ 1.
Does the harmonic series converge?
No. The standard harmonic series (r = 1) diverges as n grows, but extremely slowly — it grows approximately like ln(n) + γ, where γ ≈ 0.5772156649 is the Euler–Mascheroni constant. It takes about 12,367 terms for the partial sum to exceed 10, and roughly 1.5 × 10^43 terms to exceed 100.
What are harmonic numbers used for?
Harmonic numbers appear in the average-case analysis of algorithms such as quicksort, in the coupon collector's problem (the expected number of draws to collect all n distinct items is about n × H_n), and in number theory, where the generalized form connects directly to the Riemann zeta function.