TITLE: Divergence for $p$ prime numbers and convergence for $m$ composite numbers
QUESTION [13 upvotes]: Does there exist a sequence $(a_n)_{n\in \mathbb N} \in \mathbb C^{\mathbb N}$ such that  :

For all $p$ prime numbers the series $\displaystyle \sum_{n\in \mathbb{N}} a_n^p$ diverges,
  and for all composite $m>0$ the serie  $\displaystyle  \sum_{n\in \mathbb N} a_n^m$ converges ?

My guess :
I know there exist a serie $\displaystyle\sum \frac{\cos(\frac{2}{3}\pi n)}{\ln(1+n)}$ converge but
$$
\displaystyle\sum \left(\frac{\cos(\frac{2}{3}\pi n)}{\ln (1+n)}\right)^3
$$
diverges so I think that the answer is yes.
And I have seen that there exist a convergent serie $\displaystyle\sum  a_n$ such that
$$
\displaystyle\sum a_n^\alpha, \quad \alpha\in \mathbb{N}, \alpha>1
$$
diverges.
Proof.
For exemple
$$
a_{3k}=\frac{2}{\ln(k)}, \quad a_{3k-1}=a_{3k+1}=-\frac{1}{\ln(k)}(k=2,3,\cdots).
$$

REPLY [8 votes]: This is problem 5 from day 1 of the 2013 IMC. See here for one solution, and the official solution.