Showing that that x^2 ≡ (−1)^k (mod p). I'm stumped on using my observations to properly solve this problem. The problem is as follows:
Suppose p is an odd prime expressible as $p = 2k − 1$ and let $x$ be the product of all positive odd integers less than p. Show that $x^2 ≡ (−1)^k $(mod p).
Here are my thoughts on the problem thus far:
•   First, since x is the product of all positive odd integers less than p, so we can express x as $x = (p-2)(p-4)(p-6)…(3)(1)$
•   Thus, it follows that $x^2 = (p-2)^2 * (p-4)^2 * (p-6)^2…(3)^2 * (1)^2$.
•   Also, if $p = 2k – 1$, then $k = (p + 1) / 2$.  In this case, dividing is permissible, since $(p + 1)$ is always an even number, so dividing that by 2 always results in an integer.
•   I also noticed that whenever k is even, then $(-1)^k$ is always 1, and whenever k is odd, then $(-1)^k$ is odd.
•   We want to show, somehow, that $(p-2)^2 * (p-4)^2 * (p-6)^2…(3)^2 * (1)^2 ≡ (−1)^k$ (mod p). By plugging in some examples, this statement was demonstrably true, but I’m stuck about how to leverage all of these observations to get to what I want to show. Also, my apologies for not using the MathJax as I'm still getting used to all this.
 A: Recall that $(p-1)! \equiv -1 \pmod{p}.$ Note that
$$(p-1)! = x \cdot (2 \cdot 4 \cdots (p-1)) = x \cdot 2^{\frac{p-1}{2}} \cdot \left(1 \cdot 2 \cdots \frac{p-1}{2}\right).$$
So,
$$-1 \equiv x \cdot 2^{\frac{p-1}{2}} \cdot \left(\frac{p-1}{2}\right)! \pmod{p}.$$
Squaring this, we get that
$$1 \equiv x^2 \cdot 2^{p-1} \cdot \left(\left(\frac{p-1}{2}\right)!\right)^2 \pmod{p}.$$
$2^{p-1} \equiv 1\pmod{p}$ by Fermat's little theorem. So, now we just show that the factorial squared is $(-1)^k.$
Note that we can rewrite
$$\left(\left(\frac{p-1}{2}\right)!\right)^2 \equiv (-1)^{\frac{p-1}{2}} \cdot (p-1)! \pmod{p},$$
since
$$(-1)^{\frac{p-1}{2}} \left(\frac{p-1}{2}\right)! \equiv (p-1)(p-2)\cdots \left(p - \frac{p-1}{2}\right),$$
so that we get the latter half of the factorial. Using that $k-1 = \frac{p-1}{2},$ we can conclude
$$\left(\frac{p-1}{2}\right)!^2 \equiv (-1)^{k-1} \cdot (-1) \equiv (-1)^k \pmod{p},$$
which we showed above was equivalent to your desired identity.
A: Using Wilson’s Theorem:
$$-1 \equiv (p-1)! \equiv 1*3 *... (2k-3)*2*4*...*(2k-2)$$
$$\equiv x * (-2k+3)*...*(-3)*(-1)$$
$$\equiv x^2 *(-1)^{k-1}$$
Thus, $x^2\equiv (-1)^k$
