Convergent integral of divergent function On one of my calculus lectures I was told that there exist convergent improper integrals (in infinity) of divergent function. I was searching for an example in the internet, but I didn't find any. Has any of you idea how would this kind of function look like? Thanks in advance

For any positive integer $n$, let $f(x)=0$ at $x=n-\frac{1}{2^{n}}$. Let it climb linearly to $1$ at $x=n$, and then fall linearly to $0$ at $x=n+\frac{1}{2^{n}}$. Let $f(x)=0$ everywhere else. 
So $f$ has fast-narrowing "spikes" of height $1$ around every positive integer. The combined area of these spikes is small. 
We can modify the construction to make the maximum height of the spikes become arbitrarily large as $n\to\infty$, for example by replacing $f(n)=1$ by $f(n)=n$.  
