# For how many primes $p$ is $p^2 + 2$ is also prime? [duplicate]

For how many primes $p$ is $p^2 + 2$ also prime?

I'm not sure but I think you can consider every prime number as $(3k+1)$ or $(3k+2)$

• You can consider every prime number $\geqslant 5$ as $6k+1$ or $6k-1$, which is really the same thing, so you're right – Mr Pie Apr 12 '18 at 15:23
• It's always a good idea to write out examples. I think you'll quickly see a common factor to all such numbers. (well, $p\neq 3$ anyway). – lulu Apr 12 '18 at 15:28
• Approach0 is a better search engine than the on-site search when you need to include TeX-snippets. – Jyrki Lahtonen Apr 12 '18 at 16:39

A prime of the form $p=6k+1$ results in $$p^2+2=36k^2+12k+3=3 \times (12k^2+4k+1)$$ which is clearly divisible by $3$.

While $p=6k-1$ results in $$p^2+2=36k^2-12k+3=3 \times (12k^2-4k+1)$$ which is again divisible by $3$.

So no prime $p \ge 5$ gives $p^2+2$ as a prime too. You can check for $p<5$ easily. Turns out that $3$ satisfies this. Which is only such prime.

• Yeh thx, that means that only 3 is the answer – Andrei Rk Apr 12 '18 at 15:30
• @AndreiRk Yes, you are correct – Jaideep Khare Apr 12 '18 at 15:32
• @JaideepKhare Can you give me some references for this kind of elementary number theory ? Thanks ! – Learning Apr 12 '18 at 16:21
• I did pretty much the same as you did but your answer targets the question more :) – Mr Pie Apr 12 '18 at 17:12
• @PrithiviRaj I would recommend you to see examples of an elementary number theory book. For instance, there is a book by Arihant Publications, written by Rajeev Manocha, a book for INMO. It covers Number Theory as well as Inequalities, Geometry, Combinatorics etc. If you read the examples and solve its exercises, you'll get to know a lot of interesting stuff and new techniques to solve questions, even a lot harder than this one! (There are a lot of books out there, but this is the one I read ^_^) – Jaideep Khare Apr 12 '18 at 17:23

You don't need to consider cases. Clearly $p=3$ is only one solution less than or equal $3$. Assuming now $p>3$, we have $3 \nmid p$ and by Fermat's Little Theorem $p^2+2\equiv 1+2\equiv 0 \pmod {3}$, a contradiction. So $p=3$ is the only solution.

Assume $p=3k+1$ or $p=3k+2$ ($k$ is a natural number).

• If $p=3k+1$ then $p^2+2=9k^2+6k+3$, divisible by $3$.

• If $p=3k+2$ then $p^2+2=9k^2+12k+6$, divisible by $3$.

For every positive integers $k\ge1$ (this makes $p^2+2>3$), if $p$ is not divisible by $3$ then $p^2+2$ is divisible by $3$, this can't be true because $p^2+2$ is a prime number.

This makes $k=0$, then $p=2$ because $p$ is a prime number. If $p=2$ then $p^2+2=6$, this is not a prime number.

Because of all the above, $p=3k+1$ and $p=3k+2$ are incorrect, so we eliminated them entirely and $p$ must be divisible by $3$.

We conclude that $p=3$ is the only solution (as $p^2+2=11$).

• Looking at your expressions for $p^2+2$ in terms of $k$, it's clear that $k=1$ doesn't need to be a special case. – Joffan Apr 12 '18 at 16:28
• @Joffan Thanks for noticing, if you use $p^2+2$ instead of $p$ prime, you can eliminate an extra choice, which is $k=1$. – user061703 Apr 12 '18 at 16:35

The square of any integer is either 0 or 1 mod 3. If $p^2$ is 1 mod 3, then $p^2 +2$ is divisible by 3. If it is 0 i.e. $3|p^2$ then $3|p$ and $p=3$ is the only solution.

We will not consider $p=2$ because $2^2+2=6$ which is obviouly not prime.

Most definitely $p\neq n^2 + 1$ for all odd $p$ because if we assume otherwise, we want $$(n^2+1)^2+2=n^4+2n^2+3$$ to be prime. Therefore $3\nmid n$. (The only prime divisible by $3$ is $3$ itself, so $n=0$ is a solution, but note that $0^2+1=1$ which is neither prime nor composite.) Every prime is of the form $3k+1$ or $3k+2$, so if $p=n^2+1$ then $p\neq 3k+1$ and thus $p= 3k+2$. \begin{align}\therefore n^2+1&=3k+2 \\ \Leftrightarrow 3k&=n^2-1 \\ &=(n+1)(n-1).\end{align} Since $$(n+1)-(n-1)=2<3$$ then $3\mid n+1$ or $3\mid n-1$ but not both. $$\therefore n = 3l+1\text{ or } 3l-1$$ which when we substitute, we get that $3\mid p^2+2$ for all odd $p = n^2+1$.

It is also provable by induction that $3\mid n^4 + 2n^2$ for all integers $n$. The same result is thus implied.

For $p=2$ we get $$p^2+2=6$$ for $p=3$ we get $$p^2+2=11$$ If $$p\equiv 1\mod 3$$ we get $$p^2+2\equiv 0 \mod 3$$ For $$p\equiv 2 \mod 3$$ we get $$p^2+2\equiv 0 \mod 3$$

• $p^2 + 2 = 6$ *, for p=2 – Andrei Rk Apr 12 '18 at 15:27