(This posting is a minor revision of my answer in Math.StackExchange.)

Let $(a_n)_{n\geq 1}$ be a sequence of complex numbers, and consider the function $S(x)$ defined by

\[\begin{equation*} S(x) = \sum_{n=1}^{\infty} a_n \cos\left(\frac{x}{n}\right). \end{equation*}\]

This sum converges for all $x \in \mathbb{C}$ if and only if $\sum_{n=1}^{\infty} a_n$ converges, which we assume henceforce.

In this posting, we give an elementary proof of:

Theorem. $S(x)$ converges as $x \to \infty$ if and only if $a_n = 0$ for all $n$.

Proof. Assume that $S(x)$ converges to some $A \in \mathbb{C}$ as $x \to \infty$. Define $R(x)$ by

\[R(x) = \frac{2S(x) - S(x+2) - S(x-2)}{4}.\]

Then by invoking trigonometric identities, we get

\[\begin{align*} R(x) = \sum_{n=1}^{\infty} b_n \cos\left(\frac{x}{n}\right), \qquad b_n = a_n \sin^2\left(\frac{1}{n}\right). \end{align*}\]

Since the sum $\sum_{n=1}^{\infty} b_n$ converges absolutely, $R(x)$ converges absolutely and uniformly on $\mathbb{R}$. This allows us to write:

\[\begin{align*} \frac{1}{T} \int_{0}^{T} \lvert R(x)\rvert^2 \, \mathrm{d}x &= \sum_{m,n \geq 1} b_m \overline{b_n} \cdot \frac{1}{T} \int_{0}^{T} \cos\left(\frac{x}{m}\right)\cos\left(\frac{x}{n}\right) \, \mathrm{d}x. \end{align*}\]

Now we focus on the integral

\[I_{m,n}(T) = \frac{1}{T} \int_{0}^{T} \cos\left(\frac{x}{m}\right)\cos\left(\frac{x}{n}\right) \, \mathrm{d}x.\]

Clearly $\lvert I_{m,n}(T) \rvert \leq 1$. Moreover, it is easy to check that $I_{m,n}(T) \to \frac{1}{2}\delta_{m,n}$ as $T \to \infty$, where $\delta_{m,n} = \mathbf{1}[m = n]$ is the Kronecker delta. So by the dominated convergence theorem for series,

\[\begin{align*} \lim_{T\to\infty} \frac{1}{T} \int_{0}^{T} \lvert R(x) \rvert^2 \, \mathrm{d}x &= \sum_{m,n \geq 1} b_m \overline{b_n} \cdot \lim_{T \to \infty} I_{m,n}(T) \\ &= \frac{1}{2} \sum_{n=1}^{\infty} \lvert b_n \rvert^2. \end{align*}\]

However, the assumption tells that $R(x) \to \frac{2A - A - A}{4} = 0$ as $x \to \infty$, hence

\[\begin{align*} \lim_{T\to\infty} \frac{1}{T} \int_{0}^{T} \lvert R(x) \rvert^2 \, \mathrm{d}x &= 0. \end{align*}\]

Therefore $b_n = 0$ for all $n$, which then implies that $a_n = 0$ for all $n$.