Harmonic Number Calculator
The Harmonic Number Calculator computes the nth harmonic number H(n), which is the sum of the reciprocals of the first n positive integers: 1 + 1/2 + 1/3 + ... + 1/n.
How to Use the Harmonic Number Calculator
Interactive calculator available after JavaScript loads.
Loading calculator...
Math & Finance Experts — Verified Formulas, Peer-Reviewed Sources, Expert Analysis
Looking for a deeper explanation?
Read our comprehensive, peer-reviewed educational article in our Blog to learn the underlying math, formulas, and step-by-step examples.
Mathematical Formula & Logic
Step-by-Step Worked Calculation
Scenario: Example: Calculate H(5)
Find the 5th harmonic number.
Step 1: H(5) = 1 + 1/2 + 1/3 + 1/4 + 1/5.
Step 2: 1 = 1.000000.
Step 3: + 1/2 = 0.500000 — 1.500000.
Step 4: + 1/3 = 0.333333 — 1.833333.
Step 5: + 1/4 = 0.250000 — 2.083333.
Step 6: + 1/5 = 0.200000 — 2.283333.
Step 7: H(5) ≈ 2.283333.
How to Use the Harmonic Number Calculator
- 1. Enter the positive integer n.
- 2. Click "Calculate" to compute the nth harmonic number.
- 3. View the partial sum and its approximation.
- 4. Review the step-by-step breakdown below the result.
What Is a Harmonic Number Calculator?
The nth harmonic number H(n) is the sum of the reciprocals of the first n positive integers. The harmonic series (sum of all reciprocals) diverges, but very slowly.
Why This Calculation Matters
Harmonic numbers appear in analysis, number theory, computer science (algorithm analysis), probability, and the study of the Riemann zeta function.
Historical Background
The harmonic series was studied by medieval mathematicians. Nicole Oresme proved its divergence around 1350. The Euler-Mascheroni constant was studied by Euler in the 18th century.
Common Mistakes to Avoid
- Confusing harmonic numbers with the harmonic series (infinite sum)
- Using the approximation for small n (it is inaccurate for small values)
- Forgetting that harmonic numbers grow logarithmically (very slowly)
- Confusing H(n) with H_n notation
Frequently Asked Questions
Complete indexable directory of answers (23 questions)
What is a harmonic number?
The nth harmonic number H(n) is the sum of reciprocals: 1 + 1/2 + 1/3 + ... + 1/n.
Does the harmonic series converge?
No, the harmonic series diverges. However, it diverges very slowly — H(n) grows like ln(n).
What is the Euler-Mascheroni constant?
γ ≈ 0.5772 is defined as the limit of H(n) - ln(n) as n — ∞. It appears throughout number theory and analysis.
How do I approximate H(n) for large n?
Use H(n) ≈ ln(n) + γ + 1/(2n) - 1/(12n²). This is accurate to many decimal places for large n.
What is H(1)?
H(1) = 1. It is the first and simplest harmonic number.
How fast do harmonic numbers grow?
H(n) grows logarithmically: H(n) ≈ ln(n) + γ. Doubling n increases H(n) by approximately ln(2) ≈ 0.693.
What is the alternating harmonic series?
1 - 1/2 + 1/3 - 1/4 + ... = ln(2). Unlike the regular harmonic series, this converges.
Where do harmonic numbers appear in computer science?
They appear in the analysis of algorithms like quicksort, hash tables, and the coupon collector problem.
What is the digamma function?
The digamma function ψ(n) = H(n-1) - γ is the logarithmic derivative of the gamma function, generalizing harmonic numbers.
Can harmonic numbers be negative?
No. For positive integers n, H(n) is always positive and increasing.
What is the product formula for harmonic numbers?
H(n) = ∫₀¹ (1 - xⁿ)/(1 - x) dx, expressing the harmonic number as an integral.
How is the harmonic series related to the Riemann zeta function?
H(n) is a partial sum of the zeta function ζ(1), which diverges. The zeta function ζ(s) converges for s > 1.
What is the relationship between harmonic numbers and primes?
H(p-1) ≡ 0 (mod p) for prime p > 3 (Wolstenholme's theorem).
Can I compute H(n) for non-integer n?
Yes, using the digamma function: H(x) = ψ(x+1) + γ, which extends harmonic numbers to real and complex values.
What is the maximum harmonic number I can compute?
For practical purposes, you can compute H(n) for n up to about 10^15 before precision becomes an issue.
How is the harmonic mean related to harmonic numbers?
The harmonic mean is the reciprocal of the arithmetic mean of reciprocals. The name "harmonic" comes from the harmonic series.
What is the generalized harmonic number?
H(n,m) = 1 + 1/2ᵐ + 1/3ᵐ + ... + 1/nᵐ generalizes to power m, connecting to the Riemann zeta function.
What is the asymptotic expansion of H(n)?
H(n) = ln(n) + γ + 1/(2n) - 1/(12n²) + 1/(120n⁴) - ... with terms involving Bernoulli numbers.
How do harmonic numbers relate to factorials?
H(n) = (n+1)! × Σ 1/k!/((n+1-k)!) for k=1 to n, connecting to the binomial coefficients.
What is the largest known value of H(n)?
Harmonic numbers have been computed to arbitrary precision. For n = 10^100, H(n) ≈ 230.2585093... using the asymptotic formula.
What mathematical formula does the Harmonic Number Calculator use?
The Harmonic Number Calculator uses standard mathematical formulas validated against authoritative references. The specific formula is displayed in the calculator interface with a detailed explanation of each variable.
How can I verify the Harmonic Number Calculator results manually?
Each calculator includes a step-by-step worked example showing exactly how the formula is applied. You can follow these steps with pen and paper to verify any result.
What types of inputs does the Harmonic Number Calculator accept?
The Harmonic Number Calculator accepts numeric inputs including integers and decimals. Invalid inputs (letters, special characters) are rejected with clear error messages.