Limit of a continuous function Suppose that $f$ is a continuous and real function on $[0,\infty]$. How can we show that if $\lim_{n\rightarrow\infty}(f(na))=0$ for all $a>0$ then $\lim_{x\rightarrow+\infty} f(x)=0$? 
 A: $\newcommand{\orb}{\operatorname{orb}}$If $f(x)\not\to 0$ as $x\to\infty$, then there is an $\epsilon>0$ such that for every $m\in\Bbb N$ there is an $x_m\ge m$ such that $|f(x_m)|\ge\epsilon$. Since $f$ is continuous, for each $m\in\Bbb N$ there is a $\delta_m>0$ such that $|f(x)|>\frac{\epsilon}2$ for all $x\in(x_m-\delta_m,x_m+\delta_m)$. For $n\in\Bbb N$ let $$U_n=\bigcup_{k\ge n}(x_k-\delta_k,x_k+\delta_k)\;.$$
For $a\in(0,1)$ let $\orb(a)=\{na:n\in\Bbb Z^+\}$, and for $n\in\Bbb N$ let $$G_n=\{a\in(0,1):\orb(a)\cap U_n\ne\varnothing\}\;.$$ Suppose that $0<b<c<1$, and let $$V(b,c)=\bigcup_{n\in\Bbb Z^+}(nb,nc)=\bigcup_{x\in(b,c)}\orb(x)\;.$$ Let $m=\left\lfloor\frac{b}{c-b}\right\rfloor+1$; $(n+1)b<nc$ for each $n\ge m$, so $V(b,c)\supseteq(mb,\to)$. It follows that $V(b,c)\cap U_n\ne\varnothing$ for each $n\in\Bbb N$ and hence that $(b,c)\cap G_n\ne\varnothing$ for each $n\in\Bbb N$. Thus, each $G_n$ is a dense open subset of $(0,1)$, so by the Baire category theorem $G=\bigcap_{n\in\Bbb N}G_n$ is dense in $(0,1)$ and in particular, $G\ne\varnothing$.
Fix $a\in G$. Then $a\in G_n$ for each $n\in\Bbb N$, so $\orb(a)\cap U_n\ne\varnothing$ for each $n\in\Bbb N$. This clearly implies that $\left\{n\in\Bbb Z^+:|f(na)|>\frac{\epsilon}2\right\}$ is infinite, contradicting the hypothesis that $\lim_{n\to\infty}f(na)=0$, and we conclude that $\lim_{x\to\infty}f(x)=0$.
Added: Since you’re having trouble with the notion of proof by contradiction, let me note that I need not have phrased it that way: with a small change in wording this becomes a proof of the contrapositive of the desired statement. Since a statement and its contrapositive are logically equivalent, it proves the desired statement as well.
The desired statement has the form $A\land B\Rightarrow C$, where $A$ is the hypothesis that $f$ is continuous, $B$ is the hypothesis that $\lim_{n\to\infty}f(na)=0$ for each $a>0$, and $C$ is the desired conclusion, that $\lim_{x\to\infty}f(x)=0$. As I phrased my argument, it has the following form: 

Assume $A,B$, and $\lnot C$, and infer $\lnot B$, thereby showing that $A\land B\land\lnot C\Rightarrow B\land\lnot B$. Since $B\land\lnot B$ is a contradiction, the hypthesis $A\land B\land\lnot C$ is false. But we’re given that $A$ and $B$ are true, so it must be $\lnot C$ that’s false, and therefore, given that $A$ and $B$ are true, $C$ must be true.

I could, however, have cast the argument in the following form with very minor changes in wording:

Assume $A$. Then $\lnot C\Rightarrow\lnot B$, which is logically equivalent to $B\Rightarrow C$, so $A\land B\Rightarrow C$.

Specifically, I could have written this for the last paragraph:

Fix $a\in G$. Then $a\in G_n$ for each $n\in\Bbb N$, so $\orb(a)\cap U_n\ne\varnothing$ for each $n\in\Bbb N$. This clearly implies that $\left\{n\in\Bbb Z^+:|f(na)|>\frac{\epsilon}2\right\}$ is infinite, and hence that $\lim_{n\to\infty}f(na)\ne 0$. That is, we’ve shown that if $f(x)\lnot\to 0$ as $x\to\infty$, then there is at least one $a>0$ such that $\lim_{n\to\infty}f(na)\ne 0$. This is logically equivalent to the assertion that if $\lim_{n\to\infty}f(na)=0$ for every $a>0$, then $f(x)\to 0$ as $x\to\infty$, which is what we wanted to prove.

A: This is a standard (moderately tough) exercise in applying the Baire category theorem. Tim Gowers did a presentation of this result on his blog under the title "What is deep mathematics?".
But as he writes: 

If you haven’t seen this before and want to get the most out of this post then you should (of course) make a serious attempt to solve this beautiful problem before reading on.

