Harmonic Number Calculator - Sum the H_n Series
Use this harmonic number calculator to read H_n, the generalized H_n(r), exact rationals, partial sums, and the asymptotic ln(n) + gamma approximation.
Harmonic Number Calculator
Results
What Is a Harmonic Number Calculator?
A harmonic number calculator adds the reciprocals 1, 1/2, 1/3, ..., 1/n and reports the partial sum H_n alongside the exact rational numerator/denominator and the asymptotic ln(n) + gamma approximation. The same calculator also handles the generalized harmonic number H_n^(r) = sum of 1/k^r for any non-negative power r.
- • Partial sum of the harmonic series: Read H_10, H_100, and H_1000 in one panel without setting up a loop, so textbook exercises and exam drills are easier to verify.
- • Generalized harmonic number of order r: Switch r to 2 to get H_n^(2) = 1 + 1/4 + 1/9 + ... + 1/n^2, which converges to zeta(2) = pi^2/6 = 1.6449 as n grows, and use the same UI for any non-negative real order.
- • Exact rational partial sums: Read the unreduced numerator and denominator of H_n for any n up to 50, so the result is auditable in arithmetic or number-theory homework.
- • Convergence and divergence of the harmonic series: Compare H_10, H_100, H_1000 in the same panel to see the slow logarithmic growth that makes the harmonic series diverge even though its terms shrink to zero.
The harmonic number H_n is one of the few named series that appears in calculus, number theory, and probability at the same time. The reference values H_10, H_100, and H_1000 in one panel make it easy to read off the speed of a harmonic-style tail.
If your list of values already exists and you only need the reciprocal average, the Harmonic Mean Calculator is the right starting point before switching to a harmonic number.
How the Harmonic Number Calculator Works
Enter a positive integer n and an order r, then read H_n, the asymptotic ln(n) + gamma approximation, the exact rational for n up to 50, and three reference values that show the series growing.
- n: positive integer from 1 to 10000 that sets the number of reciprocal terms to add
- r: non-negative real order, with r = 1 giving the classical H_n and r >= 2 giving a convergent sum that approaches zeta(r)
- gamma: Euler-Mascheroni constant 0.5772156649015329 that limits the gap between H_n and ln(n)
The calculator adds the reciprocals one at a time with float64 precision and reports H_n, the asymptotic ln(n) + gamma + 1/(2n) - 1/(12n^2), and the exact rational numerator/denominator for n up to 50. For n = 100 the asymptotic agrees with the exact sum to 12 decimal places.
H_10 = 7381/2520 = 2.928968253968254
n = 10, r = 1, precision = 10
1 + 0.5 + 0.3333 + ... + 0.1 = 2.9289682539. LCM of 1..10 is 2520, so the exact sum is 7381/2520.
H_10 = 2.928968253968254. Rational 7381 / 2520. Asymptotic ln(10) + gamma = 2.9289682539.
This is the standard textbook H_10 value. Use it as a sanity check for any series involving the first ten reciprocals.
According to Wikipedia, Harmonic number, the nth harmonic number is H_n = 1 + 1/2 + 1/3 + ... + 1/n, and the harmonic series diverges even though its terms go to zero.
Key Concepts Behind H_n
These four ideas tell you when the harmonic number is the right tool and what the partial sum really means.
Partial sum of a divergent series
H_n is a partial sum of the harmonic series 1 + 1/2 + 1/3 + ... The series diverges to infinity, but H_n stays finite for every finite n. The growth is so slow that H_1000 is only about 7.485.
Generalized harmonic number H_n^(r)
Replacing 1/k with 1/k^r gives H_n^(r). For r = 1 the result is the classical H_n. For r >= 2 the partial sums converge to zeta(r), the Riemann zeta function evaluated at r.
Harmonic number vs harmonic mean
H_n is a sum of reciprocals of the running index. The harmonic mean is a reciprocal average of a list of values. The names are linked but the formulas and use cases differ.
Euler-Mascheroni constant gamma
gamma = 0.5772156649015329 is the limit of H_n - ln(n) as n grows. It tells you how far the partial sum sits above the natural log curve.
H_n is also the expected coupon count in the coupon collector problem, which is the reason coupon collection is O(n ln n) and not O(n) as the number of coupons grows.
The harmonic number H_n also appears in the Stieltjes constants and in the Taylor expansion of the log gamma function, both of which build on the Factorial Calculator for the underlying product.
How to Use This Calculator
Pick a positive integer n and an order r, then read H_n alongside the asymptotic value, the exact rational for small n, and three reference values that show the slow growth of the harmonic series.
- 1 Enter n: Type the number of reciprocals to add, between 1 and 10000. The default of 10 is the textbook H_10 example.
- 2 Choose the order r: Leave r = 1 for the classical harmonic number. Switch r to 2 for the sum of 1/k^2. Use r = 0 to read n directly.
- 3 Set decimal places: Pick a precision from 0 to 15. The default of 10 matches the textbook H_10 value 2.9289682539 to 10 figures.
- 4 Read H_n and the asymptotic: Use H_n as the canonical answer. The asymptotic column uses ln(n) + gamma + 1/(2n) - 1/(12n^2).
- 5 Inspect the reference values: The H_10, H_100, and H_1000 rows show the slow divergence of the harmonic series and give a sense of scale.
- 6 Pull the exact rational when n <= 50: The numerator and denominator outputs give the unreduced fraction form of H_n. The result is exact, not rounded.
Type n = 100 and r = 1. The calculator reports H_100 = 5.187377517639620, the asymptotic ln(100) + gamma = 5.187377517639621, and the reference values H_10 = 2.9289, H_1000 = 7.4854. The asymptotic and the exact sum agree to 12 decimal places.
When you need the closed-form sum of 1 + 2 + ... + n rather than 1 + 1/2 + ... + 1/n, the Arithmetic Sequence Calculator returns the matching triangular number for the same index.
Benefits of Using This Calculator
The harmonic number calculator saves time on the four tasks that show up most often with H_n.
- • Read H_n without setting up a loop: Get the partial sum of 1 + 1/2 + ... + 1/n in a single row, so textbook exercises and exam drills are easier to verify than a hand calculation or a quick script.
- • See the divergence trend in one panel: The H_10, H_100, and H_1000 reference rows show the slow logarithmic growth that makes the series diverge, which is the key visual for any explanation of why the harmonic series diverges.
- • Compute generalized H_n^(r) with the same UI: Switch r to 2, 3, or 4 to get partial sums that approach zeta(r). One tool covers the classical series, the Basel problem, and the Apéry constant.
- • Pull the exact rational for n <= 50: Read the unreduced numerator/denominator when the problem asks for a fraction, then reduce the fraction by hand. The result is auditable, not just approximate.
- • Compare H_n to the asymptotic approximation: Use the ln(n) + gamma + 1/(2n) - 1/(12n^2) row to estimate the partial sum for large n without summing thousands of reciprocals by hand.
- • Use the tool as a zeta table for small r: For r >= 2 the limit of H_n^(r) is zeta(r). Set n high enough to read the first few digits of zeta(2) = 1.6449340668 or zeta(3) = 1.2020569.
The benefit is not that the calculator is faster than a script, but that the layout keeps H_n, the asymptotic, and the reference values in one panel.
Pair the harmonic number with a simple arithmetic mean of the same n values via the Average Calculator to see how much faster the simple average grows than the harmonic partial sum.
Factors That Affect Your Results
Five factors and two caveats shape the value of H_n and the asymptotic approximation.
Size of n
H_n grows like ln(n) + gamma. Doubling n adds about ln(2) = 0.6931 to the partial sum. The growth is logarithmic, not linear, which is what makes the harmonic series diverge so slowly.
Order r
For r = 1 the sum diverges. For r >= 2 the sum converges to zeta(r). For r = 0 the sum is n by convention. The same UI returns the partial sum for any non-negative r.
Float64 precision
Adding 1/k for k up to 10000 keeps about 12 decimal places of accuracy. For n = 10000 the partial sum is about 9.787. Beyond n = 10000 the float64 ceiling starts to matter.
Reference values H_10, H_100, H_1000
These three reference rows let you see the slow divergence in one panel. Use them to confirm that the H_n you just computed sits in the expected range.
Asymptotic expansion
ln(n) + gamma + 1/(2n) - 1/(12n^2) approximates H_n to more decimal places as n grows. For n = 100 the asymptotic and the exact sum agree to 12 decimal places.
- • The exact rational numerator/denominator are only shown for n up to 50. Beyond that, the integer growth is too fast and the calculator suppresses the rational row.
- • The asymptotic uses the first four terms of the Euler-Maclaurin expansion. For n smaller than 5 the approximation is rough.
For high-precision research work the user can lift the exact partial sum into a computer algebra system since gamma is itself irrational and any decimal answer is a finite approximation.
According to MathWorld, Harmonic Number, the generalized harmonic number of order r is H_n^(r) = sum_{k=1}^{n} (1 / k^r), and the special case r = 1 reduces to the classical harmonic number.
According to Wikipedia, Euler's constant, the Euler-Mascheroni constant gamma = 0.5772156649015328606 limits the difference between the harmonic number H_n and the natural logarithm of n.
For another named integer family that often appears in the same number-theory problem sets as H_n, the Pythagorean Triples Calculator is a useful neighbour to keep open in another tab.
Frequently Asked Questions
Q: What is a harmonic number and how is it calculated?
A: The nth harmonic number is the partial sum H_n = 1 + 1/2 + 1/3 + ... + 1/n. You add n reciprocals, then report the total. For example, H_4 = 1 + 0.5 + 0.333... + 0.25 = 2.08333...
Q: What is the formula for the nth harmonic number?
A: The formula is H_n = sum_{k=1}^{n} (1/k). The closed form is a finite sum, not a single fraction. The exact rational for H_10 is 7381 / 2520, which equals 2.9289682539 to 10 decimal places.
Q: Does the harmonic series converge or diverge?
A: The harmonic series H_1 + H_2 + H_3 + ... diverges to infinity. The partial sum H_n grows like ln(n) + gamma, where gamma is the Euler-Mascheroni constant. The series diverges even though each term 1/n shrinks toward zero.
Q: What is the difference between a harmonic number and a harmonic mean?
A: A harmonic number is a partial sum of reciprocals: H_n = 1 + 1/2 + ... + 1/n. A harmonic mean is a reciprocal average of a list of values: H = n / (1/x_1 + ... + 1/x_n). The names are related but the formulas are different.
Q: What is the Euler-Mascheroni constant and how is it relates to harmonic numbers?
A: The Euler-Mascheroni constant gamma = 0.5772156649 is the limit of H_n - ln(n) as n grows. It is the offset that tells you how far the partial sum sits above the natural log curve, and it appears in the asymptotic expansion H_n = ln(n) + gamma + 1/(2n) - 1/(12n^2) + ...
Q: How do you compute a generalized harmonic number of order r?
A: Use H_n^(r) = sum_{k=1}^{n} (1/k^r). For r = 1 the result is the classical harmonic number. For r = 2 the partial sums converge toward zeta(2) = pi^2/6 = 1.6449340668 as n grows. For r >= 2 the sum is finite and approaches zeta(r).