I'm currently working in the following Wilson's theorem excercise:
Being $p$ an odd prime. Let $x=((p-1)/2)!$
Using the fact that $(p − 1)! = (1(p − 1)) (2(p − 2)) · · · (((p − 1)/2)((p + 1)/2))$ show that: $$-1 \equiv (-1)^{(p-1)/2}x^2 \pmod p$$
I'm starting from:
$$(1(p − 1)) (2(p − 2)) · · · (((p − 1)/2)((p + 1)/2))\equiv -1 \pmod p$$
My plan is to simplify terms on the left side to reach that $(p-1)/2$ which is the power of that $-1$, but I really don't know how can it be raised to that power, any hint or help will be really appreciated.
As Lord Shark the Unknown implies in the question comment, note that in each set of brackets, you have factors, congruent to $p$, of $k$ and $-k$ going from $k = 1$ to $k = \left(p−1\right)/2$, e.g., in $\left(1\left(p - 1\right)\right)$, it is $1$ and $p - 1 \equiv -1 \pmod p$ and in $\left(2\left(p - 2\right)\right)$, it is $2$ and $p - 2 \equiv -2 \pmod p$, all the way to $\left(\left(\left(p−1\right)/2\right)\left(\left(p+1\right)/2\right)\right)$, it is $\left(p−1\right)/2$ and $\left(p + 1\right)/2 \equiv -p + \left(p + 1\right)/2 \equiv -\left(p - 1\right)/2 \pmod p$. As such, each factor of $1, 2, \ldots, \left(p−1\right)/2$ is repeated twice (so altogether the product is $x^2$), plus you have $\left(p−1\right)/2$ factors of $-1$. Using this along with Wilson's Theorem that
$$\left(p-1\right)! \equiv -1 \pmod p$$
gives that
$$\left(p-1\right)! \equiv -1 \equiv \left(-1\right)^{\left(p-1\right)/2}x^2 \pmod p$$