Q:

Positive continuous function with non-zero limits in $\pm\infty$ whose integral over $\mathbb{R}$ is $1$?

Is it possible to create a positive continuous function with non-zero limits in $+\infty$ and $-\infty$ whose integral over $\mathbb{R}$ is $1$? 
I am studying the probability density functions and one of the conditions mentioned are that limits of the function in $+\infty$ and $-\infty$ must be $0$. Can't wrap my head around that.

A:

If one limit or the other at infinity exists, then it must be zero. Otherwise you can choose large $M$ so that $f>\varepsilon$ for $x>M$ (or $x<-M$, depending), in which case $\int_M^\infty f = +\infty$. Then the overall integral can't converge.
However, you can have a probability density with no limit at infinity. For example, if $f(x)=\begin{cases} 4x & 0 \leq x \leq 1/2 \\ 2-4(x-1/2) & 1/2 \leq x \leq 1 \\ 0 & \text{otherwise} \end{cases}$ 
then $g(x)=\sum_{n=1}^\infty f(2^n(x-n))$ is a probability density (and is a continuous function). Its graph looks like infinitely many triangles of height $2$ and width $2^{-n}$, so they have area $2^{-n}$ for $n=1,2,\dots$. It has no limit at infinity, because $g(n+2^{-n-1})=2$ for every natural number $n$, but $g(n)=0$ for all natural numbers $n$. (Also, this function is continuous and nonnegative, so there is no issue of Riemann vs. Lebesgue.)
It takes some work, but you can even make such a function infinitely differentiable. Notably it cannot be made uniformly continuous.

