RosettaCodeData/Task/Harmonic-series/00-TASK.txt
2023-07-01 13:44:08 -04:00

29 lines
1.5 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

In mathematics, the '''n-th''' harmonic number is the sum of the reciprocals of the first '''n''' natural numbers:
<!-- mathml not working
<math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>H</mi><mi>n</mi></msub><mo>=</mo><mn>1</mn><mo>+</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo>+</mo><mfrac><mn>1</mn><mn>3</mn></mfrac><mo>+</mo><mo>&#x22EF;</mo><mo>+</mo><mfrac><mn>1</mn><mi>n</mi></mfrac><mo>=</mo><munderover><mo>&#x2211;</mo><mrow><mi>k</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></munderover><mfrac><mn>1</mn><mi>k</mi></mfrac></math>
-->
<big>'''H<sub>''n''</sub> = 1 + 1/2 + 1/3 + ... + 1/n'''</big>
The series of harmonic numbers thus obtained is often loosely referred to as the harmonic series.
Harmonic numbers are closely related to the [[wp:Riemann_zeta_function|Riemann zeta function]], and roughly approximate the [[wp:Natural_logarithm|natural logarithm function]]; differing by <big>&gamma;</big> (lowercase Gamma), the [[wp:EulerMascheroni_constant|EulerMascheroni constant]].
The harmonic series is divergent, albeit quite slowly, and grows toward infinity.
;Task
* Write a function (routine, procedure, whatever it may be called in your language) to generate harmonic numbers.
* Use that procedure to show the values of the first 20 harmonic numbers.
* Find and show the position in the series of the first value greater than the integers 1 through 5
;Stretch
* Find and show the position in the series of the first value greater than the integers 6 through 10
;Related
* [[Egyptian fractions]]
<br>