TITLE: For which primes p is $p^2 + 2$ also prime?
QUESTION [6 upvotes]: Origin —  Elementary Number Theory — Jones — p35 — Exercise 2.17 —
For which primes $p$ is $p^2 + 2$ also prime?
Only for $p = 3$. If $p \neq 3$ then $p = 3q ± 1$
for some integer $q$, so
$p^2 + 2 = 9q^2 ± 6q + 3$ is divisible by $3$, and is therefore composite.
(1) The key here looks like writing $p = 3q ± 1$. Where does this hail from? I know $3q - 1, 3q, 3q + 1$ are consecutive. $p$ is prime therefore $p \neq 3q$?
(2) How can you prefigure $p = 3$ is the only solution? Does $p^2 + 2$ expose this? On an exam, I can't calculate $p^2 + 2$ for many primes $p$ with a computer — or make random conjectures.

REPLY [3 votes]: Whenever you see a quantity of the form $x^2  + a$ in a basic number theory course (especially in hw. or on an exam), you will want to think about what
divisibilities it has by various small numbers.
E.g. any square is either $\color{purple}0$ or $\color{teal}1$ $\begin{cases}\mod 3, & \text{ depending on whether or not $3$ divides $x$} \\ \mod 4, & \text{depending on whether or not $2$ divides the number being squared} \end{cases}$,
and $0,$ $1$, or $4$ mod $8$ (depending on whether or not $2$ or $4$ divide the number being squared).
Thus, when you see $p^2 + 2$, you should think: $\begin{cases} = \color{purple}0 + 2 & \mod3 \text{ , if $3$ divides $p$} \\ = \color{teal}1 + 2 \equiv 0 & \mod3 \text{ , if $3 \not| p$} \end{cases}$.
Since the only prime that can be $0$ mod $3$ is $3$ (and $p^2 + 2$ will certainly be $> 3$), this answers your question
immediately.