Let $S$ be a sequence of positive odd integers. Find a sequence in which $\sum_{n=1}^{\infty}x_{n}^{k}$ converges iff$k \in S$ I am trying to solve Q14 of the 2016-17 Analysis I example sheet I from the university of Cambridge:

https://www.dpmms.cam.ac.uk/study/IA/AnalysisI/2016-2017/sheet1.pdf

Let $S$ be a possibly infinite set of odd positive integers. Prove that there exists a real sequence $(x_{n})$ such that for each $k \in \mathbb{N}, \; \sum_{n=1}^{\infty}x_{n}^{k}$ conveges iff $k \in S$.


I do not currently posses any intuition on how to tackle this problem. I'm trying to begin by finding a sequence $(a_{n})$ in which $\sum_{n=1}^{\infty}x_{n}$ converges but $\sum_{n=1}^{\infty}x_{n}^{k}$ for $k\neq1$.


On a separate note, I am aware that the solution to this problem can be found in the American Mathematical Monthly, Vol. 53, No. 5 (May 1946) pp. 283-284, but I do not currently have access to the solution nor do I think that seeing the solution to the problem will help me gain some intuition on it.


Any Help would be greatly appreciated. Thank you.
 A: I suggest working the opposite way, ie constructing sequences such that the series of their odd powers converge except for one specific $k$ (I'll call them elementary sequences with index $k$). Indeed, it sounds likely that when mixing several elementary sequences (with different indices), then the divergence will occur for any index of some of the elementary sequences, and convergence will occur everywhere else.
To make it clearer: if $\sum_n{a_n^k}$ converges when $k=3,7,9$ and not when $k=5,11$, and if $\sum_n{b_n^k}$ converges when $k=5,7,9$ but not when $k=3,11$, then, if $c$ is the sequence $a_0,b_0,a_1,b_1,\ldots$, $\sum_n{c_n^k}$ converges when $k=7,9$, but not when $k=3,5$ -- and it's probably going to be pretty hard to say what happens when $k=11$.
Once one of your components is divergent, it's harder to compensate for it. So an idea is to "mix" elementary sequences, enough of them so that  all integers not in $S$ are indices of at least one of them.
Under spoilers is how you construct such "elementary sequences":

So, the case where $S$ is all integers except a certain $k=2\ell+1$. The harmonic series works well if $\ell=0$, so assume $\ell \geq 1$.

We take $x_n$ of the form $\frac{a_n}{n^{1/k}}$ where $a_n$ is $k$-periodic. Asymptotics show that the required condition on the $a_n$ is that $\sum_{i=1}^k{a_i^p}=0$ if $1 \leq p < k$ is odd, and said sum is different from zero if $p=k$.

Consider now the map $\Phi(b_0,\ldots,b_{\ell})=\left(\sum_{i=0}^{\ell}{b_i^{2p+1}}\right)_{0 \leq p \leq \ell}$. It's easy to see that if $0=b_0 < b_1 < \ldots < b_{\ell}$, then $\Phi'(b)$ is invertible, and there thus exists a vector $c$ close to $b$ such that $\Phi(c)-\Phi(b)$ is only nonzero on the last coordinate.

I'm adding a second spoilers for what's below since this adjustment is key to the general case and meaningless to the specific case.

We choose as weights $a=(-c_0,-c_1,\ldots,-c_{\ell},b_1,\ldots,b_{\ell})$ (which has $k$ coefficients indeed, so we are good) and normalize so that $\|a\|_{\infty} < 1$.


When $S$ contains all odd integers but finitely many, how to mix the "elementary sequences" is quite easy, there are more difficulties about how to deal with infinitely many divergences. In particular, it's not obvious that infinitely many convergences (conditional, most of them) can "add up" to something which still converges. I'll let you try and think of a fix (a possibility is in spoilers).

 For a general $S$, consider a bijection $\psi$ between the set of odd positive integers not in $S$ and a proper subset $P$ of odd primes.

Choose, for each $p \in P$, $y^{(p)}$ a sequence corresponding to $\psi^{-1}(p)$ by the construction above (ie $\sum_n{(y^{(p)}_n)^k}$ converges iff, for odd $k$, $k \neq \psi^{-1}(p)$).

Define $x_n$ as follows: $x_{2^n} = \frac{(-1)^n}{\log(n)}$ (to prevent any convergence for even powers), and $x_{p^n} = a_py^{(p)}_n$ for every $p \in P$, where we'll define $a_p > 0$ later, and $x_n=0$ for integers neither powers of $2$ nor of any prime of $P$.

We set $$a_p = \frac{2^{-p^2}}{1+\sup_{n > m \geq 1,k \neq \psi^{-1}(p), k\text{ odd}}\,\left|\sum_{s=m}^n{(y^{(p)}_s)^k}\right|}.$$

Now we need to check that convergence occurs for exactly the elements of $S$. We already saw the case of even integers, and the series of the $x_{2^n}^k$ always converges for odd $k$, so we can pretend that $x_{2^n}=0$ instead.

Let $k \in S$. Let $n > m$. Then, for any $p \in P$, using the definition of the $a_q$, and the fact that $0 < a_q < 1$ so that $|a_q|^k \leq |a_q|$, $$\left|\sum_{s=m}^n{x_s^k}\right| \leq \sum_{q \in P, q \geq p}{2^{-q^2}}+\sum_{q \in P, q < p}{\left|\sum_{\log_q{m} \leq s \leq \log_q{n}}{(y^{(q)}_s)^k}\right|},$$ so that $$\limsup_{m,n \rightarrow \infty}\,\left|\sum_{s=m}^n{x_s^k}\right| \leq \sum_{q \geq p}{2^{-q^2}},$$ and thus $\sum_{n \geq 1}{x_n^k}$ converges.

Let $k \notin S, \psi(k)=p_0 \in P$. Let $z_n=x_n$ if $n$ is a power of $p_0$, $z_n=0$ otherwise. The exact same argument as the above shows that $\sum_{n \geq 1}{(x_n-z_n)^k}$ converges, and, as $x_n^k=(x_n-z_n)^k+z_n^k$, $\sum_{n \geq 1}{z_n^k}$ converges iff $\sum_{n \geq 1}{x_n^k}$ converges. But the first series doesn't converge, because it is constructed not to.

Thus $\sum_{n \geq 1}{x_n^k}$ converges iff $k \in S$.

