Every natural number is representable as $\sum_{k=1}^{n} \pm k^5$ ... if somebody proves it for 240 integers

Here's a solution for general $p$:

For general $p$, we only have to check numbers $0 \leq x < C_{p}$. But now actually it also suffices to check all the residue classes modulo $C_{p}$. Now the point is that \begin{eqnarray*} \sum_{n = 1}^{C_{p}^2}n^{p} &=& \sum_{n = 1}^{C_{p}}n^{p} + \sum_{n = C_{p} + 1}^{2C_{p}}n^{p} + \ldots + \sum_{n = (C_{p}-1)C_{p} + 1}^{C_{p}^2}n^{p} \\ &\equiv& \sum_{n = 1}^{C_{p}}n^{p} + \sum_{n = 1}^{C_{p}}n^{p} + \ldots + \sum_{n = 1}^{C_{p}}n^{p} \\ &\equiv & C_{p}\sum_{n = 1}^{C_{p}}n^{p} \\ &\equiv& 0 \mod C_{p} \end{eqnarray*} but now changing the first sign to minus we get $$ -1^p+2^p+3^p+\ldots + (C_{p}^2)^p \equiv -2 \mod C_p $$ Now for any even residues just continue like that; for $-2m$ just take $mC_{p}^2$ numbers such that the sign is minus if and only if $n \equiv 1 \mod C_{p}^2$. Finally for odd residues add one final power, which is of the form $(kC_{p}+1)^p \equiv 1 \mod C_{p}$.

This proves that any residue is attainable with at most $\frac{C_{p}^3}{2} + 1$ consecutive signed powers; using this it would take quite a lot of them to get numbers form $0$ to $C_p$, but it works.


For $n \leq 27$, I know that almost every $N$ with $0 \leq N < 240$ has at least one representation in the form $$N = \sum_{k=1}^n \pm k^5,$$ and I have a list of those representations. (I'm still missing $n=71$ and $131$ and $133$.)

I wrote a Python script which brute forces all $2^n$ possibilities for $\pm$, but it takes quite a while to run. (And as Erick Wong points out in the comments, this probably isn't really necessary.)

The output and code are a bit long to include in an answer here, so here’s a link to the script and the results on GitHub: https://github.com/alexwlchan/drabbles/tree/master/python/powers

I feel pretty confident that the last two values are attainable, but I won't find them myself. (I can't think of any reason why $71$ and $131$ would be the sole exceptions, but after nearly three hours, I’m stopping the script.)


Now that I've stopped, here are a few comments:

  • Brute-forcing all $2^n$ values is really slow. This approach probably isn’t practical for larger values of $N$. You’d want to look for a pattern in what $\pm$ combinations work, and limit your search space accordingly – as Erick Wong suggests in the comments.

  • Finding new values was fairly bursty. It could go a long time without finding anything new, and then suddenly a dozen or so values would appear at once. Unfortunately I didn’t record the order, but this might be useful for spotting a pattern in what works and what doesn’t.