Constructing a counterexample to: if $\lim_nf(an)= 0$ for every $a>0$ then $\lim_{x\to \infty} f(x)$ exists. [duplicate]
Solution 1:
Let us use only the fact that an irrational number $\beta$ exists. For this define $$f(x)=\begin{cases}1&x-\beta\in\Bbb Q\\0&\text{otherwise}\end{cases}$$ Then for each $a>0$, at most one $f(na)$ is non-zero. Indeed, if $na=r+\beta$ and $ma=s+\beta$ with $n\ne m$, then $mr+m\beta=man=ns+n\beta$ and $\beta=\frac{mr-ns}{n-m}\in \Bbb Q$, contradiction. Hence $f(na)\to0$, whereas $f(x)=1$ on a dense set.
Solution 2:
This is not an explict construction but I hope you are interested in this. By induction we can find a sequence $(x_n)$ increasing to $\infty$ such that $\frac {x_n} {x_i}$ is irrational for $1 \leq i < n, (n \geq 1)$. [Use the fact that $\mathbb Q$ is countable and $\mathbb R$ is uncountable] Let $f(x)=1$ if $x \in \{x_1,x_2,\cdots\}$ and $f(x)=0$ otherwise. This $f$ has the desired properties.