# Prove that there are infinity numbers that you can't write them in the form of $a^2+p$ where $a$ is a integer and $p$ is a prime.

Prove that there are infinity numbers that you can't write them in the form of $a^2+p$ where $a$ is a integer and $p$ is a prime.

The book wrote the answer all numbers in the form of $(3k+2)^2$ where $k$ is an integer but I can't show why?

Hint: rewrite as $p=(3k+2)^2-a^2$ and note that if $a$ is not divisible by $3$ the difference of squares is, and if $a$ is divisible by $3$ you get a factorisation which shows $p$ cannot be prime.
Incidentally, with $k=0$ you have $2^2=1^2+3$ which is a counter-example - perhaps $k$ is supposed to be a positive integer? There are still an infinite number of examples to provide an answer to the original question.
Suppose that $(3k+2)^2$ can be written in the form $a^2+p$, then $(3k+2)^2-a^2=p$ and $(3k+2-a)(3k+2+a)=p$. Note that $3k+2 \neq a$. Now, $p=(3k+2-a)(3k+2+a)$ is a composite number unless $p=3k+1$, which gives $p=6k+3$. It is composite again. Contradiction.
• You need to exclude $a=3k+1$ too - not difficult, but has to be done. May 29, 2017 at 16:18