Harmonic Number Calculator
Calculate harmonic number instantly with our math tool. Shows detailed work, formulas used, and multiple solution methods.
Reviewed for accuracy by Manoj Kumar, Mathematics Educator
Harmonic Number Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: H_n = 1 + 1/2 + 1/3 + ... + 1/n
Worked example โ H_10 = 2.928968 | Approximation = 2.8798 | Harmonic mean = 3.414
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 H_10 = 2.928968... Approximation: ln(10) + gamma = 2.3026 + 0.5772 = 2.8798 Difference: H_10 - ln(10) = 0.6263 (approaching gamma = 0.5772) Harmonic 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 H_10^(2) = 1.54977 The infinite sum converges to zeta(2) = pi^2/6 = 1.64493 H_10^(2) captures 94.2% of the infinite sum Remaining 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.
What is the Euler-Mascheroni constant and why is it important?
The Euler-Mascheroni constant gamma (approximately 0.5772156649) is defined as the limit of H_n - ln(n) as n approaches infinity. It represents the difference between the discrete harmonic sum and the continuous natural logarithm. Despite being one of the most important constants in mathematics, it is still unknown whether gamma is rational or irrational, which remains one of the major unsolved problems in mathematics. The constant appears in many areas including number theory (distribution of prime numbers), analysis (the Gamma function), and probability theory. The approximation H_n is approximately equal to ln(n) + gamma + 1/(2n) - 1/(12n^2) provides excellent accuracy for computing harmonic numbers for large n.
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.
What is the relationship between harmonic numbers and the natural logarithm?
Harmonic numbers are closely approximated by the natural logarithm: H_n is approximately equal to ln(n) + gamma, where gamma is the Euler-Mascheroni constant. This relationship arises because the harmonic sum H_n = sum(1/k, k=1..n) approximates the integral of 1/x from 1 to n, which equals ln(n). The difference H_n - ln(n) converges to gamma as n grows. More precise asymptotic expansions give H_n approximately equal to ln(n) + gamma + 1/(2n) - 1/(12n^2) + 1/(120n^4) - ... This relationship connects discrete sums with continuous integrals and is an example of the Euler-Maclaurin formula, a powerful tool for approximating sums by integrals.
What is the alternating harmonic series and what does it sum to?
The alternating harmonic series is 1 - 1/2 + 1/3 - 1/4 + 1/5 - ... = sum((-1)^(n+1)/n, n=1..infinity). Unlike the standard harmonic series, this alternating version converges, and its sum is exactly ln(2) = 0.693147... This can be proven using Taylor series: ln(1+x) = x - x^2/2 + x^3/3 - x^4/4 + ..., and substituting x = 1 gives ln(2). The alternating series converges conditionally but not absolutely (since the absolute values form the divergent harmonic series). By the Riemann rearrangement theorem, rearranging the terms can make the series converge to any desired value, which demonstrates the importance of distinguishing absolute from conditional convergence.
How do harmonic numbers relate to the Riemann zeta function?
The Riemann zeta function zeta(s) = sum(1/n^s, n=1..infinity) is the limit of the generalized harmonic number H_n^(s) as n approaches infinity, for s > 1. Famous values include zeta(2) = pi^2/6, zeta(4) = pi^4/90, and zeta(6) = pi^6/945. The connection to harmonic numbers provides a discrete approximation to the zeta function: H_n^(s) approaches zeta(s) as n increases. The Riemann hypothesis, one of the most important unsolved problems in mathematics, concerns the zeros of the zeta function and has deep connections to the distribution of prime numbers. Harmonic numbers and the zeta function together form a bridge between discrete mathematics and analytic number theory.
What is the harmonic mean and how does it use harmonic numbers?
The harmonic mean of the first n positive integers is n / H_n, where H_n is the nth harmonic number. More generally, the harmonic mean of values x_1, x_2, ..., x_n is n / (1/x_1 + 1/x_2 + ... + 1/x_n). The harmonic mean is always less than or equal to the geometric mean, which is less than or equal to the arithmetic mean (HM-GM-AM inequality). The harmonic mean is particularly useful when averaging rates or ratios. For example, if you drive 60 mph for half the distance and 40 mph for the other half, your average speed is the harmonic mean: 2/(1/60 + 1/40) = 48 mph, not the arithmetic mean of 50 mph. It appears in physics for parallel resistances and in finance for price-earnings ratios.
How fast do harmonic numbers grow compared to other sequences?
Harmonic numbers grow logarithmically, which is extremely slow compared to polynomial or exponential growth. H_10 is approximately 2.93, H_100 is approximately 5.19, H_1000 is approximately 7.49, and H_10000 is approximately 9.79. Each tenfold increase in n adds only about 2.30 (which is ln(10)) to the harmonic sum. By contrast, the sum of the first n integers (n(n+1)/2) grows quadratically, and geometric sums grow exponentially. This slow growth explains why algorithms with harmonic-number complexity (like quicksort with O(n log n)) are considered very efficient. The partial sums of the harmonic series reach 10 after about 12,367 terms and would need approximately 10^43 terms to reach 100.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator ยท Editorial policy
Related Calculators
๐งฎSum of a Linear Number Sequence Calculator
Calculate sum of alinear number sequence with inputs, formulas, and instant results.
๐งฎComplex Number Calculator
Calculate complex number with inputs, formulas, and instant results.
๐งฎHarmonic Mean Calculator
Calculate harmonic mean with inputs, formulas, and instant results.
๐งฎPrime Number Calculator
Calculate prime number with inputs, formulas, and instant results.
๐งฎAbundant Number Checker
Calculate abundant number checker with inputs, formulas, and instant results.
๐งฎDeficient Number Checker
Calculate deficient number checker with inputs, formulas, and instant results.
๐งฎImproper Fraction to Mixed Number Calculator
Calculate improper fraction to mixed number with inputs, formulas, and instant results.
๐งฎMixed Number Calculator
Calculate mixed number with inputs, formulas, and instant results.