# Legendre symbol $p ≡ 5 \mod 8$

I need to prove: If $$p$$ is a prime number congruent to $$5 \mod 8$$, and $$\left(\frac np\right)= 1$$, then

either $$[n^{(p+3)/8}] ^2 ≡ n\bmod p$$

or $$[n^{(p+3)/8}((p-1)/2)! ]^2 ≡ n\bmod p$$

I am not really sure how to proceed, although I have tried checking the cases $$n= 1$$ and $$n = -1$$, I have also tried various things with the definition of a Legendre symbol.

We know that $$n$$ is a quadratic residue. The question is whether $$n$$ is a quartic residue or not.
• Assume first that $$n\equiv a^4\pmod p$$ for some $$a$$ coprime to $$p$$. By Little Fermat we can deduce that $$1\equiv a^{p-1}\equiv n^{(p-1)/4}\pmod p.$$ Multiplying this congruence by $$n$$ gives $$n^{(p+3)/4}\equiv n\pmod p.$$ As $$k=(p+3)/8$$ is an integer, this means that $$(n^k)^2\equiv n$$ in line with the first alternative.
• If $$n$$ is a modular square but not a modular fourth power, then I first claim that $$-n$$ will be a fourth power modulo $$p$$. This is because $$-1$$ is known to be a quadratic residue. But as $$p\not\equiv 1\pmod 8$$ there are no elements of order $$8$$, and consequently $$-1$$ cannot be a fourth power. The claim follows from this because the quotient group of quadratic residues modulo quartic residues is cyclic of order two (this holds for all $$p\equiv1\pmod4$$). The result of the previous bullet thus implies the congruence $$(-n)^{(p+3)/4}\equiv -n\pmod p.$$ Here $$(p+3)/4$$ is even, so this reads $$n^{(p+3)/4}\equiv -n\pmod p.\qquad(*)$$
• Let $$u$$ be the residue class of $$((p-1)/2)!$$. Because $$p\equiv1\pmod4$$ it follows from Wilson's theorem, $$(p-1)!\equiv-1\pmod p$$, that $$u^2\equiv-1\pmod p$$. This allows us to rewrite congruence $$(*)$$ in the form $$[u n^{(p+3)/8}]^2\equiv n^{(p+3)/4}u^2\equiv (-n)\cdot (-1)=n\pmod p,$$ which is exactly what the second alternative says.