<s>[INST] Find all primes $p$ such that $p^3-4p+9=x^2$, where $x$ is a positive integer. Problem:Find all primes $p$ such that $p^3-4p+9=x^2$, where $x$ is a positive integer.
My Attempt: I have made the following observations while trying tot solve this problem: 


*

*$p=2$ yields $x=3$.

*For $p>2$ the following is true: $x^2\equiv 0\pmod 4$ and $p\equiv 3\pmod 4.$ 

*It seems that $p=2,7$ and $11$ are the only primme numbers that satisfy the conditions of this problem. Below are the values of $p^3-4p+9$ evaluated for $1\leq p\leq 100.$


9
24
114
324
1296
2154
4854
6792
12084
24282
29676
50514
68766
79344
103644
148674
205152
226746
300504
357636
388734
492732
571464
704622
912294
I would like to know how one can prove that $p=2,7$ and $11$ are the only solutions to the above-mentioned equation.
 [/INST] If $p^3-4p+9=n^2$ then $n^2\equiv 9 \pmod{p}$ and $\pm n \equiv 3 \pmod{p}$ since $n^2-9\equiv 0$ can only have two roots modulo a prime.
We then have
$$
\begin{array}{ll}
n^2=(-n)^2 &= (kp+3)^2 \\
p^3-4p+9 &= k^2p^2+6kp+9 \\
0 &= p^2-k^2p-(6k+4) \\
p & = \frac{k^2\pm \sqrt{k^4+24k+16}}{2}
\end{array}
$$where we used $p\ne 0$ since it's a prime. This can only have an integer solution for $p$ when $k^4+24k+16$ is a square.
But
$$
\begin{array}{ll}
(k^2-1)^2 = k^4-2k^2+1 < k^4+24k+16<(k^2)^2 & \text{if }k<-11 \\
(k^2)^2 < k^4+24k+16< k^4+2k^2+1 =(k^2+1)^2 & \text{if }k>12
\end{array}
$$so if $k<-11$ or $k>12$ then $k^4+24k+16$ lies between two squares and hence is not a square. This leaves 24 values to check, which you could do by hand. It leads to solutions when $k=-3,0,3$ which give integral values for $p$ of $-2,2,7,11$, of which only $2,7,11$ are prime.
</s>