# Prime integer p such that -1 is a square mod p

Can we describe those prime numbers $$p$$ for which $$p-1$$ is a perfect square $$\bmod p$$.

For example, it is true for $$p=2$$ and $$p=5$$.

• You mean so that there is a number $a$ so that $a^2 \equiv (-1) \mod{p}$? Well, for $11$ it doesn't work ... – Matti P. Oct 25 '19 at 8:01
• 1 mod 4, and 2 ${}$ – mathworker21 Oct 25 '19 at 8:01
• @MattiP. Yes. It also doesn't work for $p=7$. But it does work for $p=13$ – Tusif Ahmed Oct 25 '19 at 8:08
• So the answer is no. – Matti P. Oct 25 '19 at 8:11

$$2$$ works, so suppose $$p$$ is odd. If $$a^2 \equiv -1 \pmod{p}$$, then $$a^4 \equiv 1 \pmod{p}$$, so the order of $$a$$ mod $$p$$ divides $$4$$. Since $$a \not \equiv 1$$ and $$a^2 \not \equiv 1$$ (since $$-1 \not \equiv 1$$, since $$p > 2$$), we must have $$ord_p(a) = 4$$. Since $$a^{p-1} \equiv 1 \pmod{p}$$ (Fermat's little theorem), we must have $$4 \mid p-1$$, i.e., $$p \equiv 1 \pmod{4}$$.
Now suppose $$p \equiv 1 \pmod{4}$$. Then $$x^4-1$$ divides the polynomial $$x^{p-1}-1$$. Since $$x^{p-1}-1$$ has exactly $$p-1$$ roots in $$\mathbb{Z}_p$$, and since $$\frac{x^{p-1}-1}{x^4-1}$$ has at most $$p-5$$ roots (since $$\frac{x^{p-1}-1}{x^4-1}$$ has degree $$p-5$$), it must be that $$x^4-1$$ has exactly $$4$$ roots. Since $$x^2-1$$ has exactly $$2$$ roots, it must be that $$x^2+1$$ has exactly $$2$$ roots. So it in particular has a root, which is what we want.