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.