# Prove that if $p>2$ is prime then $\left(\prod_{k=1}^{p-1}k^k\right)^2\equiv (-1)^{\frac{p+1}2}\pmod p.$

Prove that if $p>2$ is prime then $$\left(\prod_{k=1}^{p-1}k^k\right)^2\equiv (-1)^{\frac{p+1}2}\pmod p.$$ I find this by computer but cannot prove it, thank you!

-
What is meant by $f^4(p)$? Does it mean $(f(p))^4$? Or does it mean $(fofofof)(p) = f(f(f(f(p))))$? –  Saaqib Mahmuud Dec 8 '13 at 8:59
@Saaqib Mahmuud, $(f(p))^4$, thank you! –  Hecke Dec 8 '13 at 9:03
Just as a minor comment : t = Hyperfactorial[p-1] –  Claude Leibovici Dec 8 '13 at 9:26

Let's deal with the stuff inside the square first. Since $p-1$ is even we have that:

$\prod_{k=1}^{p-1} k^k \equiv \left(\prod_{k=1}^{\frac{p-1}{2}} k^k\right) \left(\prod_{k=1}^{\frac{p-1}{2}} (-k)^{p-k}\right) = (-1)^{\frac{p-1}{2}} \prod_{k=1}^{\frac{p-1}{2}}k^p \equiv (-1)^{\frac{p-1}{2}}\prod_{k=1}^{\frac{p-1}{2}}k \quad\bmod p$.

So $\left(\prod_{k=1}^{p-1} k^k\right)^2 \equiv \left(\left(\frac{p-1}{2}\right)!\right)^2 \bmod p$.

Now if $p\equiv 1 \bmod 4$ then:

$\left(\left(\frac{p-1}{2}\right)!\right)^2 \equiv (p-1)! \equiv -1 \equiv (-1)^{\frac{p+1}{2}} \bmod p$.

Whereas if $p \equiv 3 \bmod 4$ then:

$\left(\left(\frac{p-1}{2}\right)!\right)^2 \equiv -(p-1)! \equiv 1 \equiv (-1)^{\frac{p+1}{2}} \bmod p$.

-
Shouldn't there be a $p-k$ in the first line? It cancels out when taking congruency, so it doesn't matter much. –  Horstenson Dec 8 '13 at 10:07
Yes but I have skipped that step since the positioning of the brackets makes it clear what I have done. –  fretty Dec 8 '13 at 10:13
Ok, might be better to use congruency symbols instead of equality though, otherwise it's somewhat wrong as there is no equality. –  Horstenson Dec 8 '13 at 10:18
Yes, I made a typo, I have fixed this. –  fretty Dec 8 '13 at 10:18
Can you explain the first line a bit more?More specifically,why is $\prod_{k=1}^{p-1} k^k \equiv \left(\prod_{k=1}^{\frac{p-1}{2}} k^k\right) \left(\prod_{k=1}^{\frac{p-1}{2}} (-k)^{p-k}\right)$? –  rah4927 Dec 8 '13 at 12:58
show 1 more comment