22a. Harmonic
Short review question.
The harmonic-add
function takes in a start
and an end
number,
and finds the sum 1/start + 1/(start+1) + ... + 1/end
.
(check-expect (harmonic-add 1 2) 1.5)
(check-within (harmonic-add 1 3) 1.8333 0.0001)
(check-within (harmonic-add 1 4) 2.0833 0.0001)
Example in math: (harmonic-add 1 4)
is
$$ \frac{1}{1} + \frac{1}{2} + \frac{1}{3} + \frac{1}{4}. $$
Another example: (harmonic-add 3 7)
is
$$ \frac{1}{3} + \frac{1}{4} + \frac{1}{5} + \frac{1}{6} +
\frac{1}{7}. $$