If $f(x)$ is continuous and $ \lim_{x\to \infty} f(x)=1$, does this guarantee that the $\displaystyle \int_0^\infty f(x) dx$ diverges? Just as I described in the question, if $ f(x)$ is continuous on $[0,\infty]$ and
$$ \displaystyle \lim_{x\to \infty} f(x)=1$$
Then what about this integration?
$$\displaystyle \int_0^\infty f(x) dx$$
For me, I'm a little bit suspicious that the integration is guaranteed to be divergent. My idea is from function $\dfrac{\sin x}{x}$ that is a continuous function. At the same time: $$ \lim_{x\to \infty}\dfrac{\sin x}{x}=0$$  and $$ \int_0 ^\infty \dfrac{\sin x}{x} \ dx =\dfrac{\pi}{2}$$
This function is "oscillating" up and down on the x-axis in a suitable way resulting in it being convergent.
Then, I think that maybe there can also exist a function, but it is oscillating on $ y=1$ in a very suitable way which makes it convergent

Failed example, plz ignore this:
Then I think by constructing a piece wise continuous function:
$$\begin{cases} 
f(x) = \dfrac{\sin x}{x} +1 & \forall x\in[2k\pi,(2k+1)\pi] \\ \\ 
f(x) = \dfrac{\sin x}{x} -1 & \forall x\in[(2k+1)\pi,(2k+2)\pi] 
\end{cases}$$ for $k=0,1,2...$

But I'm not certain whether my idea is right and can't really come up with any counterexamples.
Also if the integration is indeed guaranteed to be divergent, I don't know how to prove it.
Any helps? Thanks!
 A: Yes, even if $\int_{0}^{\infty}f(x)dx$ is defined in improper sense.
Let $F(x)=\int_{0}^{x}f(t)dt$. Suppose the contrary that $I=\lim_{x\rightarrow\infty}F(x)$
exists. For $\varepsilon=1$, there exists $x_{1}>0$ such that $|F(x)-I|<\varepsilon$
whenever $x\geq x_{1}$. Since $\lim_{x\rightarrow\infty}f(x)=1>\frac{1}{2}$,
there exists $x_{2}>0$ such that $f(x)>\frac{1}{2}$ whenever $x\geq x_{2}$.
Take $x_{3}=\max(x_{1},x_{2})+1$, $x_{4}=x_{3}+100$. On one hand,
\begin{eqnarray*}
|F(x_{4})-F(x_{3})| & \leq & \left|F(x_{3})-I\right|+\left|F(x_{4})-I\right|\\
 & < & 2\varepsilon\\
 & = & 2.
\end{eqnarray*}
On the other hand,
\begin{eqnarray*}
 &  & |F(x_{4})-F(x_{3})|\\
 & = & \left|\int_{x_{3}}^{x_{4}}f(t)dt\right|\\
 & \geq & \int_{x_{3}}^{x_{4}}\frac{1}{2}dt\\
 & = & \frac{1}{2}(x_{4}-x_{3})\\
 & = & 50.
\end{eqnarray*}
We obtain a contradiction.
A: Continuity is not required. Since $\lim_{x\to\infty} f(x)=1$, there is some $x_0>0$ such that for all $x>x_0$ we have $f(x)>\frac{1}{2}$. In order for $\int_0^{\infty} f(x) \, dx$ to converge $\int_{x_0}^{\infty} f(x) \, dx$ must converge.
$\int_{x_0}^{\infty} \frac{1}{2} \, dx$ clearly diverges, as $\int_{x_0}^{x} \frac{1}{2} \, dx = \frac{1}{2}(x-x_0)\overset{x\to\infty}{\to}\infty$. By the comparison test $\int_{x_0}^{\infty} f(x)\,dx$ diverges as well, so that $\int_0^{\infty} f(x) \, dx$ necessarily diverges.
A: Divergence is definitely guaranteed. Consider this: suppose that $f$ has an antiderivative $F.$ Then by L'Hopital's theorem, $$\lim_{x\to\infty}\frac{F(x)}{x}=\lim_{x\to\infty}f(x).$$ By the fundamental theorem of calculus, since $f$ is continuous, you are guaranteed that $$F(x)=\int_a^xf(t)\,\mathrm{d}t$$ for some $a.$ Therefore, $$\lim_{x\to\infty}\frac{\int_a^xf(t)\,\mathrm{d}t}{x}=1.$$ However, $$\lim_{x\to\infty}x=\infty,$$ so it necessarily is the case that $$\lim_{x\to\infty}\int_a^xf(t)\,\mathrm{d}t=\int_a^{\infty}f(t)\,\mathrm{d}t=\infty$$ as well. Why? Because if the integral were finite, then $$\lim_{x\to\infty}\frac{\int_a^xf(t)\,\mathrm{d}t}{x}=0.$$
