Hacker News new | ask | show | jobs
by lotharbot 5226 days ago
In essence, what's being computed is the sum of 1 + 1/2 + 1/3 + 1/4 + ... (which we call the harmonic series), and you're trying to figure out how fast it reaches a given number. You've experimentally verified that it takes exponential time, which is another way of saying that the sum grows like a logarithm.

To verify this mathematically, use the "integral test" [0] twice. The linked proof shows that the sum of k terms is larger than ln(k+1). It turns out that, by drawing the rectangles under instead of above the curve, you can also show that the sum of k terms is less than 1+ln(k+1). Thus, the long-term behavior of the sum is essentially the same as the long-term behavior of a (base e) logarithm.

[0] http://en.wikipedia.org/wiki/Harmonic_series_%28mathematics%...