Coding challenge

The harmonic series $1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \dots$ diverges to infinity, but it grows with agonizing slowness.

Write a while-loop that sums terms until the total sum exceeds $10$. How many terms $N$ did it take? (Ans: over $12{,}000$!).

Next, compute $\text{sum} - \ln(N)$ using math.log(n). What celebrated constant do you get? (Hint: look up the Euler-Mascheroni constant $\gamma \approx 0.577215$).

Type your code here:


Lua reference

See your results here: