For which primes $p\not=2$ is $5$ a square mod $p$?

For which primes $p\not=2$ is $5$ a square mod $p$?

Using the Legendre symbol, $5$ is a square modulo $p$ if

$$\left(\frac{5}{p}\right)=5^{\dfrac{p-1}{2}} \equiv 1 \pmod{p}$$

Now we have

$$5^{\dfrac{p-1}{2}} = (5^{p-1})^{1/2} \equiv 1\pmod{p}$$

So $5$ is a square for any $p$. But this doesn't seem correct to me. Can anyone check this and if it's wrong, explain why.

• What is the $1/2$-power supposed to mean ? – Captain Lama Apr 28 '16 at 17:58
• Can you use Quadratic Reciprocity? – André Nicolas Apr 28 '16 at 18:02
• @AndréNicolas Yes I can use the three laws. – user2850514 Apr 28 '16 at 18:09

You can't take the square root like this. By Fermat's little theorem, we know that for $p$ prime we have that $5^{p-1} \equiv 1 \mod p$. This means that $p \mid 5^{p-1} -1$, and hence $$p \mid \left(5^{\tfrac{p-1}{2}} -1\right)\left(5^{\tfrac{p-1}{2}} +1\right)$$

Therefore $5^{\tfrac{p-1}{2}} \equiv 1 \mod p$ or $5^{\tfrac{p-1}{2}} \equiv -1 \mod p$.

Note that if $p$ is not prime, there can be even more possibilities.

Note that for every odd prime $p$ we have $2 \mid p-1$. Also $4 \mid 5-1$. So $2 \mid \left(\frac{p-1}{2} \cdot \frac{5-1}{2} \right)$. Hence by quadratic reciprocity we have $$\left( \frac{p}{5} \right)\left( \frac{5}{p} \right) = (-1)^{\frac{p-1}{2} \cdot \frac{5-1}{2}} = 1$$

So $\left( \frac{p}{5} \right) =1$ if $\left( \frac{5}{p} \right)=1$, and the latter happens when $p\equiv 1 \mod 5$ or $p \equiv 4 \mod 5$.

Note that one can not use the law if $p=5$, since the law of quadratic reciprocity requires $p$ and $q$ to be different primes. Whether $p=5$ is a quadratic residue depends on the definition of quadratic residue.

• Am I correct in thinking $(p/5)=1\iff (5/p)=1$ since if $(5/p)=-1$ then their product would be $-1$? – user2850514 Apr 28 '16 at 18:25
• @user2850514 Yes. – wythagoras Apr 28 '16 at 18:32
• Please forgive this question as I am a rank amateur. I was wondering about your line "the latter happens." Might it not be that (5/p)=1 if (p/5)=1 and that happens if $p\equiv 1,4 \pmod 5$. Thanks and regards, – user12802 May 22 '16 at 12:49
• @Andrew I'm sorry, but I don't understand your question. The latter means $(5/p)=1$. $(5/p)=1$ if and only if $p \equiv 1, 4 \mod 5$. – wythagoras May 22 '16 at 12:52
• I was thinking that first one shows that (p/5) =1 for $p\equiv 1,4\pmod 5$ and then it follows that (5/p) =1 subsequently holds for $p\equiv 1,4\pmod 5$? – user12802 May 22 '16 at 13:08

The number $5$ is a square modulo the prime $5$, though I would not call it a quadratic residue of $5$. Now assume that $p$ is an odd prime other than $5$.

By Quadratic Reciprocity, since $5$ is of the form $4k+1$, we have $(5/p)=(p/5)$.

Note that $(p/5)=(r/5)$, where $r$ is the remainder when we divide $p$ by $5$.

It is easy to check that $1$ and $4$ are quadratic residues of $5$, and $2$ and $3$ are not.

Thus $(5/p)=1$ if and only if the odd prime $p$ is congruent to $1$ or $4$ modulo $5$. Equivalently, $(5/p)=1$ if and only if the rightmost decimal digit of the prime $p$ is $1$ or $9$.

• +1, but you forgot $p=5$ itself. – wythagoras Apr 28 '16 at 18:20
• @wythagoras: I dealt separately with $5$ in the first paragraph. – André Nicolas Apr 28 '16 at 18:22
• Yes, I see. But why wouldn't you call $5$ a quadratic residue of $5$? It satisfies the definition. – wythagoras Apr 28 '16 at 18:24
• @wythagoras: There are marginally different definitions of quadratic residue modulo $p$. The standard textbooks I have used exclude $0$. That way, for odd primes $p$ there are exactly as many quadratic residues as non-residues, and the product of a residue and a non-residue is a non-residue. (That result would fail if we allow $0$ as a QR.) – André Nicolas Apr 28 '16 at 18:28