# Prove that if $p$ and $p^2+2$ are prime then $p^3+2$ is prime too [duplicate]

I'm trying to figure out how to prove that if $$p$$ and $$p^2+2$$ are prime numbers then $$p^3+2$$ is a prime number too. Can someone help me please?

• The trick is that $p$ and $p^2 + 2$ are almost never both prime. Have you tried some examples? Oct 6, 2015 at 7:01
• Hint: Find what is $p\mod3.$
– CIJ
Oct 6, 2015 at 7:02
• @QiaochuYuan what about 3, 3 is prime and 11 is prime and 29 is prime ! Oct 6, 2015 at 7:04
• Prime numbers greater than $3$ are always $\pm1\bmod 6$. So $p^2+2\equiv 3\bmod 6$, and hence a multiple of $3$ (meaning not prime). Oct 6, 2015 at 7:08
• @Nizar: I said "almost never," not "never." Oct 6, 2015 at 7:10

If $p=2$, then $p^2+2$ is not prime.

If $p=3$, then $p^2+2 = 11$, then $p^3+2=29$ is prime.

If $p>3$, then $p \equiv \pm 1 \pmod 3$, then $p^2+2 \equiv 0 \pmod 3$. So, $p^2+2$ is not prime.

• For clarity you might want to add that the statement given by the OP is thus true... Oct 6, 2015 at 7:13
• So it works only for 3?
– Ergo
Oct 6, 2015 at 7:25
• Why do you bother to isolate the case $p = 2$ -- the logic holds for the same reason in the $p > 3$ case.
– MT_
Oct 6, 2015 at 7:47
• Sure, you're right. Thank you very much guys, I understood.
– Ergo
Oct 6, 2015 at 9:03

You can use the difference of squares formula to get that $$p^2 + 2 = (p+1)(p-1) + 3$$. Since $$p^2$$ is prime, $$(p+1)(p-1)$$ cannot have a factor $$3$$ as it would imply that $$p^2 + 2$$ is divisible by $$3$$ hence not a square. Among three consecutive integers one has to be divisible by $$3$$. Since neither $$p+1$$ or $$p-1$$ is divisible by $$3$$, $$p$$ must be. $$p$$ is a prime number and the only prime divisble by $$3$$ is $$3$$ itself, hence $$p =3$$ and $$p^3 + 2 = 29$$, a prime.

• Welcome to Math Stack Exchange. Your answer may be easier to read and more likely to be voted on if you edit your post using this tutorial to make it easier to read. Nov 24, 2019 at 18:05