Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|cite|improve this question
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! – Next Dec 8 '13 at 9:03
Just as a minor comment : t = Hyperfactorial[p-1] – Claude Leibovici Dec 8 '13 at 9:26
up vote 6 down vote accepted

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$.

share|cite|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.