Find the sum of all positive integers $n$ such that when $1^3+2^3+3^3 +\dots+ n^3$ is divided by $n+5$ the remainder is $17.$ 
Find the sum of all positive integers $n$ such that when $1^3+2^3+3^3 +\dots+ n^3$ is divided by $n+5$ the remainder is $17.$

Letting $k= n+5$ we get that $1^3+2^3+3^3 +\dots+ (k-5)^3 \equiv 17 \text{ (mod $k$)}$.
Knowing the sum of cubes formula we get that ($\frac{(k-5)(k-4)}{2})^2\equiv 17 \text{ (mod $k$)}$.
From here I'm not sure how I should continue. What would be my options?
 A: As $\sum\limits_{i=1}^ni^3=\frac14 n^2(n+1)^2$ we consider cases $n=2k$ and $n=2k-1$.

*

*$n=2k$, $\ \frac14 n^2(n+1)^2=(n+5)\left(2 k^3 - 3 k^2 + 8 k + \frac{100}{2 k + 5} - 20\right)$ so $(2k+5)|(100-17)$, but $100-17=83$ is a prime, thus $2k+5=83$ and $n=78$.

2a. $n=4k+1$, $\ \frac14 n^2(n+1)^2-17=(n+5)\left(16 k^3 + 13 k + \frac{83}{2 (2 k + 3)} - \frac{33}{2}\right)$ thus $\frac{83}{2 (2 k + 3)} - \frac{1}{2}$ should be a whole number, thus $\frac{83}{ (2 k + 3)}$ should be odd integer, $(2 k + 3)|83$, $k=40$ and $n=4k+1=161$
2b. $n=4k+3$, $\ \frac14 n^2(n+1)^2-17=(n+5)\left(16 k^3 + 24 k^2 + 25 k + \frac{83}{4 (k + 2)} - 8\right)$ thus $\frac{83}{4 (k + 2)}$ should be a whole number, however, it's not the case as $4\not|83$.
So the answer is $78+161$.
A: From $$n\equiv -5 \pmod{n+5} \Rightarrow \\
n^2\equiv 25 \pmod{n+5} \Rightarrow\\
n^2+n\equiv 20 \pmod{n+5} \Rightarrow \\
(n^2+n)^2\equiv 400 \pmod{n+5} \Rightarrow \\
n+5 \mid 4\cdot\left(\frac{n^2(n+1)^2}{4}-100\right)$$
but we want
$$\sum\limits_{k=1}^n k^3=\frac{n^2(n+1)^2}{4}=Q\cdot (n+5)+17$$
or
$$n+5 \mid 4\cdot\left(Q\cdot (n+5)+17-100\right)=
4\left(Q\cdot (n+5)-83\right)\Rightarrow\\
n+5\mid 2^2\cdot 83$$
which yields the following options to check
$$n+5=83$$
$$n+5=2\cdot83$$
$$n+5=2^2\cdot83$$
The first two will satisfy the initial condition, so $n=78, n=161$.
A: $\frac{1}{4}(k-5)^2(k-4)^2$ = $\frac{1}{4}(k^4-18k^3+121k^2-360k+400)$=$pk+17$ for some integer $p$. So, $\frac{1}{4}(k^4-18k^3+121k^2-360k+332)$ = $pk$ => $k$ should divide $332$ . So we get possible values of $k$ as $1,83,166,332$. As $k>4$, $k=1$ is not possible. Similarly for $k=332$, $(k^3-18k^2+121k-360+1)$ is clearly not divisible by $4$. So, $p=\frac{1}{4}(k^3-18k^2+121k-360+1) $ isn't an int, which is not possible. When $k=83$, it is easy to see that $p=\frac{1}{4}(k^3-18k^2+121k-360+4)$ is an integer(Why?). With a bit of clever reasoning you can verify that $k =166$ also fits the bill. So, $n= 78 \space and \space 161$.
A: If $S_m=\sum_{r=1}^mr^3$
$$2S_{n+4}=\sum_{r=1}^{n+4}r^3+(n+5-r)^3\equiv0\pmod{n+5}$$ as $r^3+(n+5-r)^3\equiv0\pmod{n+5}, 1\le r\le n+4$
$$\implies2S_n\equiv-2[(n+4)^3+(n+3)^3+(n+2)^3+(n+1)^3]\pmod{n+5}$$
$$\equiv-2[(n+5-1)^3+(n+5-2)^3+(n+5-3)^3+(n+5-4)^3]$$
$$\equiv2(1^3+2^3+3^3+4^3)$$
$$\implies2S\equiv200\pmod{n+5}\text{ but we need  }2S\equiv34\pmod{n+5}$$
So, the necessary & sufficient condition is
$$200\equiv34\pmod{n+5}\iff (n+5)|(200-34)$$
A: Let $$S:=\sum_{k=1}^{n} k^{3}=\left[\frac{n}{2}(n+1)\right]^{2}$$
Then  $$\begin{aligned} 4S &=[n(n+1)]^{2} \equiv[-5(-5+1)]^{2}\equiv 400 \quad (\operatorname{mod} n+5) \end{aligned}$$
Given that $S \equiv 17 \bmod (n+5)$, we have
$$
\begin{array}{l}\quad  4(17) \equiv 400 \quad (\bmod n+5) \\
\Rightarrow n+5 \mid 400-4(17)=2^{2} \times 83 \\
\Rightarrow n+51=83,2 \times 83 \text { or } 2^{2} \times 83 \text { (rejected) } \\
\Rightarrow n=78 \text { or } 161
\end{array}
$$
