Convergence of $\lim_{n \to \infty} \left(\sum_{k=1}^{n}f(k)-\int_{1}^{n+1}f\left(x\right)dx\right)$ I have seen similar questions about specific cases (see here for $f(x) = \frac{1}{\sqrt{x}}$ and here for $f(x) = \frac{1}{x^a}$). I would like to find when $$\lim_{n \to \infty} \left(\sum_{k=1}^{n}f(k)-\int_{1}^{n+1}f\left(x\right)dx\right)$$

converges. I know that one possible way for this to converge is if $\int_1^{\infty}f(x)dx \leftrightarrow \sum_{k=1}^{\infty} f(k)$ converges. However, this is not the only way for it to converge such as with $f(x)= \frac{1}{x^a}, 0 \le a \le 1$. We can split the integral into parts so that the limit becomes $$\sum_{k=1}^{\infty}\left(f(k)-\int_k^{k+1} f(x)dx \right)$$

The summand must approach $0$ for the sum to converge. I believe this only happens if $f(x)$ is a function approaching $0$. However, this probably is not sufficient for the sum to converge. This brings me to my main question:

What conditions on $f(x)$ are necessary and sufficient for $\lim_{n \to \infty} \left(\sum_{k=1}^{n}f(k)-\int_{1}^{n+1}f\left(x\right)dx\right)$ to exist?

Edit: as jvc pointed in the comments, it is not necessary for $f(x)$ to approach zero, such as with $f(x)$ a constant. I now think it is necessary (perhaps even sufficient) for $f'(x)$ to approach $0$, not necessarily $f(x)$.
A sufficient condition is that $f$ is differentiable and $\int_1^\infty |f'(x) | \, dx &lt; \infty$.

Integrating by parts we get

$$\int_k^{k+1} (x - k - 1)f'(x) \, dx = \left.(x- k- 1)f(x)\right|_k^{k+1} - \int_k^{k+1} f(x) \, dx  = f(k) -   \int_k^{k+1} f(x) \, dx$$

Thus,

$$\left|f(k) -   \int_k^{k+1} f(x) \, dx\right| = \left|\int_k^{k+1} (x - k - 1)f'(x) \, dx \right|\leqslant \int_k^{k+1} |x - k - 1|\,|f'(x)|\, dx \\ \leqslant \int_k^{k+1} |f'(x)|\, dx , $$

and we have absolute convergence of the series

$$\sum_{k=1}^{\infty}\left|f(k)-\int_k^{k+1} f(x)dx \right|\leqslant \sum_{k=1}^{\infty}\int_k^{k+1} |f'(x)|\, dx = \int_1^\infty |f'(x)| \, dx,$$

which implies convergence of 

$$\sum_{k=1}^{\infty}\left(f(k)-\int_k^{k+1} f(x)dx \right) = \lim_{n \to \infty}\left(\sum_{k=1}^{n}f(k)-\int_{1}^{n+1}f\left(x\right)dx\right)$$
can we use the fact that:
$$\int_1^{n+1}f(x)dx=\lim_{N\to\infty}\sum_{i=0}^Nf\left(1+\frac{in}{N}\right)\frac nN$$
and compare the two sums?