For which integer values of $n$ does there exist an integer $m$ such that $n^{3} - m^{2} = -23$? For which integer values of $n$ does there exist an integer $m$ such that $n^{3} - m^{2} = -23$?


I'm having a lot of trouble with this one, any help would be appreciated :)

So far, I've seen that if the expression were a perfect square we would have:
$n^{3} + 23 = x^{2}$
For some integer $x$. From this I've deduced that $n^{3}$ must be congruent to $x^{2}$ modulo $23$, however, I'm not sure how to proceed.
Suppose that $n^3+23=m^2$ for some integers $n,m$.  Observe that
$$(n+3)(n^2-3n+9)=n^3+27=m^2+4.$$

If $m$ is odd, then $n$ is even.  Since $m^2\equiv 1\pmod{8}$, we must get $n^3\equiv 1-23\equiv 2\pmod{8}$.  However, this is impossible as $n^3\equiv 0\pmod{8}$ for every even integer $n$.  Thus $m$ is even.

Since $m$ is even, say $m=2k$, we get that $n$ is odd.  Because $m^2\equiv 0\pmod{4}$, we obtain $n^3\equiv -23\equiv 1\pmod{4}$.  Thus $n\equiv 1\pmod{4}$.  That is,
$$k^2+1=\frac{m^2+4}{4}=\frac{n+3}{4}\left(n^2-3n+9\right).$$
Since $n\equiv 1\pmod{4}$, we must have
$$n^2-3n+9\equiv 1-3+9\equiv 3\pmod{4}.$$
Because $n^2-3n+9&gt;0$, we conclude that a prime natural number $p\equiv 3\pmod{4}$ must divide $n^2-3n+9$.  Thus, $k^2+1$ is divisible by $p$, so that $-1$ is a quadratic residue modulo $p$, which implies that $p\equiv 1\pmod{4}$.  This is a contradiction.
Hint: Try to prove that every perfect square is congruent to $0$ or $1(mod 4$).