Solutions of $x^3 + (x+4)^2 = y^2$ I want to solve the above equation in integers. I'm pretty sure the only solutions are $(x,y) = (0, \pm 4)$ but I'm not sure how to prove it.
 A: When $x=0$, $y^2 = 4^2$ and hence $y=\pm 4$. Thus $(x,y) = (0,\pm 4)$ are solutions. We will show there are no other solutions.
Suppose that $x \neq 0$. We have \begin{align}
 x^3 = y^2 - (x+4)^2 = (y+x+4)(y-x-4) 
 \end{align} Let $d$ be the greatest common divisor of $y+x+4$ and $y-x-4$. We claim that $d$ is a power of 2. If $d$ has an odd prime factor $p > 1$, then clearly, $p$ divides $x^3$ and hence $x$. Also since $p$ divides both $y+x+4$ and $y-x-4$, it divides their sum, $2y$ and since $p$ is odd, $p$ divides $y$. But then $p$ must divide 4, a contradiction. 
Thus $d = 2^k$ for some $k \geq 0$.Suppose that $k=0$. That is, $y+x+4$ and $y-x-4$ are coprime. Then, there exists integers $m,n$ such that $y+x+4 = m^3$ and $y-x-4=n^3$. We have $x=mn$ and $2x+8 = m^3-n^3$. Clearly, $m,n$ are both odd and hence $|m-n| \geq 2$. 
Case 1 $x=mn > 0$, $m >  n$
    $$2mn+8 = m^3-n^3 = (m-n)((m-n)^2+3mn) \geq 6mn$$ and hence $mn \leq 2$. Since $m,n$ are both odd integers, it follows that $mn \geq 3$. Thus no solutions in this case.
Case 2 $x = mn >0$, $m < n$
We have $$2mn+8 = (m-n)^3 + 3(m-n)mn \leq -8-6mn $$
    This gives $mn \leq -2$, a contradiction to the assumption $mn > 0$.
Case 3 $x = mn <0$, $m > n$
We have $2mn + 8 = m^3 - n^3 > 0$ and hence $mn > -4$. Since $m,n$ are odd integers, the possibilities are $mn = -1, -3$. Thus $m = 1, n=-1$ or $m=3, n=-3$. Putting $m=1, n=-1$, we get $-1 + 27 = y^2$, and $y $ is not an integer. For $m=3, n=-1$, we have $-27+1 = y^2$ again an impossibility.
Case 4 $x = mn < 0$, $m < n$
Here, $m < 0$ and $n > 0$.
    $$2mn + 8 = m^3 - n^3 < -m^2 - n^2$$ giving $m^2+n^2+2mn = (m+n)^2 < -8$, an impossibility.
Suppose that $d = 2^k$ and $k >0$. Since $2^{2k}$ divides $x^3$, it follows that $k$ must be a multiple of $3$. We need to discuss two cases: $k > 3$ and $k=3$. Suppose that $k > 3$. Then, $2^6 | x$. But $2^6 | (y+x+4) - (y-x-4) = 2x+8$. This implies $2^6$ divides 8, a contradiction. 
Suppose that $k=3$. Then $y+x+4 = 8a, y-x-4 = 8b$ where $a,b$ are coprime.
 We have $x^3 = 64ab$ and hence both $a,b$ must be cubes of integers. Let $a =m^3, b=n^3$. Note that both $m,n$ are odd integers. Also $x=4mn$ and $2x+8 = 8(m^3-n^3)$. Thus $mn+1 = m^3-n^3$ and since $m, n$ are both odd integers, $|m-n| \geq 2$. If $mn > 0$, then $m >n$ and $mn+1 = (m-n)((m-n)^2 + 3mn) \geq 6mn$ and we get $5mn \leq 1$, a contradiction. If $mn < 0$, two cases arise:
$m < 0, \, n > 0$: $2mn + 1 < mn+1 = m^3 - n^3 \leq  -m^2 - n^2$ giving $m^2+n^2+ 2mn \leq -1$, an impossibility. 
$m > 0,\, n < 0$: $mn+1 = m^3 - n^3 > 0$ and $mn > -1$. Since $mn < 0$ and $m, n$ are integers, this is impossible.  
Thus the only solutions of the given equation are $x=0, y=\pm 4$. 
A: A subtle proof technique called proof by SageMath:
E = EllipticCurve([0,1,0,8,16])  
E.integral_points(both_signs=True)

which gives:
[(0 : -4 : 1), (0 : 4 : 1)]

where the numbers in the constructor of the EllipticCurve are the Weierstrass coefficients of the curve. For reference, the Weirstrass coefficients are defined as a list $[a_1, a_2, a_3, a_4, a_6]$ where the curve is of the form $y^2 + a_1xy + a_3y = x^3 + a_2x^2 + a_4x + a_6$.
Try it here!
I don't want to give you a non-answer but in general I don't think there is a clean way to prove these things except by using the fact that we have terminating algorithms to find the solutions. I haven't looked at this specific case too closely (there may be a neat trick), but proof by SageMath is technically sufficient.
A few buzzwords for you to continue your search if you're interested: "weirstrass equation", "elliptic curve", "finite fields".
Here are also a few math overflow answers that are slightly more detailed:
Link 1
Link 2

Edit
The context that this is an olympiad question means there should be a neater way. I've had more time to look at this so:
We want to find all integer solutions to $x^3 + (x+4)^2 = y^2$. First notice we can write this as a difference of two squares:
$$
\begin{align}
x^3 + (x+4)^2 &= y^2 \\
x^3 &= y^2 - (x+4)^2 \\
x^3 &= (y+(x+4))(y-(x+4)) \\
x^3 &= (y+x+4)(y-x-4)
\end{align}
$$
Now, since $x$ and $y$ are integers, $(y+x+4)(y-x-4)$ must be an integer factorization of $x^3$. The ways to factor $x^3$ into two factors, if $x$ is prime, are: 


*

*$x^3 \cdot 1$

*$1 \cdot x^3$

*$x \cdot x^2$

*$x^2 \cdot x$


We can simply enumerate through each of these for the factors on the RHS of our equation and see which gives integer solutions. 
For ex. if we try the third factorization, we get $(y+x+4) = x$ and $(y-x-4) = x^2$. The first equation gives $y = -4$ and substituting into the second gives $x^2 + x + 8 = 0$ which has no integer solutions and thus this factorization won't work.
If you try all of these, you will notice no integer values for $x$ or $y$ satisfy any of those factorizations. This leaves one possibility: that $x^3 = 0$ and thus $x = 0$. Evaluating this on the RHS, we get $(y+0+4)(y-0-4) = 0$ and thus:
$$
(y+4)(y-4) = 0 \\
\implies y = \pm 4
$$
Thus the only solutions are $(x, y) = (0, \pm 4)$.
Correction:
Comment is correct, this only holds for prime $x$. Perhaps develop what could be done if $x$ is not prime or show this can't be so? This might be a good starting place.
