Determine how long a sum of $\frac{1}{n}$ is needed to reach a limit

Since

$$\lim_{n\to\infty} \sum_{i=1}^n {1 \over i} = \infty$$

it should be possible to find the $n$ where the sum reaches a certain number.

Given $c$ determine $k$ where

$$\sum_{i=1}^k {1 \over i} < c \leq \sum_{i=1}^{k+1} {1 \over i}$$

Approximate solution is also OK if you can determine whether $k$ is even or odd.

-
This page helps you with at least an approximate solution: $k\approx e^{c-\gamma}$ – Arthur Jun 18 '13 at 8:37
It is unclear to me how precise that is. Can I just round that value down or will that fail at some point? – Ole Tange Jun 18 '13 at 8:49
Any approximation will fail for suitably-chosen $c$. – Robert Israel Jun 18 '13 at 9:00

If $S_n = \sum_{i=1}^n 1/i$, we have $L(n) < S_n < U(n)$ where \eqalign{L(n) &= \ln(n) + \gamma + \frac{1}{2n} - \frac{1}{12 n^2}\cr U(n) &= \ln(n) + \gamma + \frac{1}{2n}\cr}
Now $U(x) = c$ for $$x = -\dfrac{1}{2 W(-\exp(\gamma-c)/2)}$$ where $W$ is the Lambert W function. If $n = \lfloor x \rfloor$, you have $U(n) \le c \le U(n+1)$. The difference between $L(n+1)$ and $U(n+1)$ is only $1/(12 (n+1)^2)$, while the difference between $U(n)$ and $U(n+1)$ is approximately $1/(n+1)$ which is much larger if $n$ is large. So for "most" $c$, you'll also have $c \le L(n+1)$, and therefore $S_{n} < c < S_{n+1}$. But if you're unlucky enough that $c > L(n+1)$, all you have is $L(n+1) < c < U(n+1)$. You might then try a better approximation.
For example, with $c = 10$, I get $x \approx 12366.46810$ so $n = 12366$, and $L(12367) \approx 10.00004301 > c$, so $S_{12366} < 10 < S_{12367}$.