7
$\begingroup$

Does $(p-n)!\pmod{p}$ have a closed form for any $n>2$ when $p$ is prime?

  • $(p-0)!=0 \pmod{p}$

  • $(p-1)!=-1\pmod{p}$

  • $(p-2)!=1\pmod{p}$

  • 0
    from $(p-1)!$ to $\Big(p-(p-1)\Big)$, we just traverse the reduced residue system modulo $p$. Kind of hard to say which permutation of it is encountered.2012-01-17
  • 1
    You'd need to find a formula for the multiplication inverse of $n!\pmod p$. Then $(p-n)! \equiv (-1)^{n} (n-1)!^{-1}\pmod p$ or something like that.2012-01-17
  • 0
    See also http://math.stackexchange.com/questions/461331/prove-p-kk-1-equiv-1k-text-mod-p.2013-10-03

2 Answers 2

6

Since $(p-1)! \equiv -1 \mod p$, $$(p-n)! \equiv \frac{(p-1)!}{\prod_{j=1}^{n-1} (p-j)} \equiv (-1)^{n-1} ((n-1)!)^{-1} \mod p$$

5

The only interesting case is $n=1$, which is Wilson's theorem.

The case $n=2$ follows from $n=1$ directly.

For the case $n=3$ one needs to know the multiplicative inverse of $p-2 \bmod p$, which is $(p-1)/2$. So, $(p-3)! \equiv (p-1)/2 \bmod p$.

For the case $n=4$ one needs to know the multiplicative inverse of $p-3 \bmod p$. Now $p=3t\pm1$, assuming $p\ne3$. Then $(p-4)! \equiv (p\mp 1)(p-1)/6\bmod p$.

I guess you could carry on but it seems to get messier...

  • 1
    You can write the inverse of $p-3$ as $\frac{p^2-1}3$ if you want to eliminate the $\pm 1$.2012-01-17
  • 0
    @ThomasAndrews, good point.2012-01-17
  • 1
    See also [this answer.](http://math.stackexchange.com/a/256780/242)2014-05-12