Skip to main content

Harmonic Number Calculator

Calculate harmonic number instantly with our math tool. Shows detailed work, formulas used, and multiple solution methods.

Reviewed by Manoj Kumar, Mathematics Educator

Reviewed by Manoj Kumar, Mathematics Educator

Formula

H_n = 1 + 1/2 + 1/3 + ... + 1/n

The nth harmonic number is the sum of reciprocals of the first n positive integers. The generalized form H_n^(s) sums 1/k^s for k=1 to n. For large n, H_n is approximately ln(n) + gamma where gamma = 0.5772... is the Euler-Mascheroni constant.

Worked Examples

Example 1: Computing the 10th Harmonic Number

Problem:Calculate H_10 = 1 + 1/2 + 1/3 + ... + 1/10.

Solution:H_10 = 1 + 0.5 + 0.3333 + 0.25 + 0.2 + 0.1667 + 0.1429 + 0.125 + 0.1111 + 0.1\nH_10 = 2.928968...\nApproximation: ln(10) + gamma = 2.3026 + 0.5772 = 2.8798\nDifference: H_10 - ln(10) = 0.6263 (approaching gamma = 0.5772)\nHarmonic mean of 1-10: 10/H_10 = 3.414

Result:H_10 = 2.928968 | Approximation = 2.8798 | Harmonic mean = 3.414

Example 2: Generalized Harmonic Number (s=2)

Problem:Calculate H_10^(2) = 1 + 1/4 + 1/9 + ... + 1/100 (sum of reciprocal squares).

Solution:H_10^(2) = 1 + 0.25 + 0.1111 + 0.0625 + 0.04 + 0.02778 + 0.02041 + 0.015625 + 0.01235 + 0.01\nH_10^(2) = 1.54977\nThe infinite sum converges to zeta(2) = pi^2/6 = 1.64493\nH_10^(2) captures 94.2% of the infinite sum\nRemaining sum approximately 1/(s-1) * 1/n^(s-1) = 0.1

Result:H_10^(2) = 1.54977 | zeta(2) = 1.64493 | Coverage = 94.2%

Frequently Asked Questions

What is a harmonic number and how is it calculated?

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/4 + ... + 1/n. For example, H_4 = 1 + 0.5 + 0.333... + 0.25 = 2.0833... The harmonic numbers grow without bound (they diverge), but they grow very slowly compared to n itself. The growth rate is approximately ln(n) + gamma, where gamma is the Euler-Mascheroni constant (approximately 0.5772). Harmonic numbers appear frequently in combinatorics, number theory, analysis of algorithms, and probability. They are named after the harmonic series in music, where overtone frequencies are integer multiples of a fundamental frequency.

Does the harmonic series converge or diverge?

The harmonic series (the sum of 1/n from n=1 to infinity) diverges, meaning it grows without bound. This is remarkable because the individual terms 1/n approach zero, yet their sum still grows to infinity. The classic proof groups terms in powers of 2: (1) + (1/2) + (1/3 + 1/4) + (1/5 + 1/6 + 1/7 + 1/8) + ... Each group sums to at least 1/2, so the total exceeds any finite number. However, the divergence is extremely slow. To reach a sum of 10, you need about 12,367 terms. To reach 20, you need about 272 million terms. To reach 100, you would need approximately 10^43 terms. This slow divergence makes the harmonic series a borderline case in convergence analysis.

What are generalized harmonic numbers?

Generalized harmonic numbers H_n^(s) extend the standard harmonic number by raising each denominator to a power s: H_n^(s) = 1 + 1/2^s + 1/3^s + ... + 1/n^s. When s = 1, this gives the standard harmonic numbers. When s = 2, we get the sum of reciprocal squares, which converges to pi^2/6 (the Basel problem solved by Euler). For any s > 1, the infinite sum converges to the Riemann zeta function zeta(s). For s <= 1, the series diverges. The case s = 0 gives H_n^(0) = n. Generalized harmonic numbers are useful in analytic number theory, statistical mechanics, and the analysis of random algorithms where different powers of reciprocals arise naturally.

How are harmonic numbers used in algorithm analysis?

Harmonic numbers appear frequently in the analysis of computer algorithms. The expected number of comparisons in quicksort is approximately 2n * H_n, which gives the famous O(n log n) average case. The coupon collector problem asks how many random draws are needed to collect all n distinct items: the expected number is n * H_n. In hash table analysis, the expected maximum chain length involves harmonic numbers. Skip lists have search times related to harmonic sums. The average number of steps in the Euclidean algorithm for computing GCD relates to harmonic numbers. Understanding harmonic growth (roughly logarithmic) is essential for predicting algorithm performance in practice.

References

Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy