# Prove that Legendre Symbol $\left(\frac{(p-1)!}p\right) \equiv p\pmod4$

Let $p$ be an odd prime. Prove that Legendre Symbol $\left(\frac{(p-1)!}p\right)=1$ if $p\equiv1\pmod4$, $-1$ if $p\equiv3\pmod4$.

Not sure where to begin but here are my initial thoughts.

Clearly, the only way $p$ can be an odd prime is if $p\equiv1$ or $3\pmod4$. Then I see that by Legendre Symbol properties:

$\left(\frac{(p-1)!}p\right) = \left(\frac1p\right)\cdot\left(\frac1p\right)\cdots \left(\frac{p-1}p\right)$, and this is an even number of Legendre symbols. Then by Euler's Criterion, since $p$ is an odd prime, and obviously none of $a = 1, 2, 3, \ldots, p-1$ are divisible by $p$, then $\left(\frac ap\right) \equiv a^{(p-1)/2}\pmod p$.

Not sure if this is the right path, or if I am missing something.

I made an edit to what I have so far:

Clearly, the only way $p$ can be an odd prime is if $p\equiv1\pmod4$ or $p\equiv3\pmod4$. Then, by Wilson’s Theorem we see that $\left(\frac{(p-1)!}p\right)\equiv\left(\frac{-1}p\right)\equiv\left(\frac{p-1}p\right)\pmod p$. Then, we know that from previous work, a square can be of the form $4k$, or $4k + 1$, but not $4k + 2$, or $4k + 3$. Then we see that... (not sure how to finish this off).

Use Wilson's theorem: $$(p-1)! \equiv -1 \pmod{p}$$ Then use the fact that a square can be of the form $4k$ or $4k+1$ but not of the form $4k+2$ or $4k+3$.
Working modulo $4$ does not tell you anything about the quadratic character modulo $p$. For example, no square is $3$ modulo $4$, but $3$ is a square modulo $11$, $13$, $23$, $37$ ... Similarly, $7$ is a square modulo $3$, $19$, $29$, ... (see here) $\newcommand\leg[2]{\left(\frac{#1}{#2}\right)}$ In fact the Chinese Remainder Theorem tells us that, in some sense, being a square modulo $4$ is independent of being a square modulo an odd prime $p$.
Use the fact that $$\leg{-1}p=1 \iff p\equiv1\pmod4.$$ (This is sometimes called the First supplement of the Law of Quadratic Reciprocity.)
Once you notice that $\leg{(p-1)!}p=\leg{-1}p$ (by Wilson's theorem), you're done.