7

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

JavaMan
  • 13,375
  • 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. – nb1 Jan 17 '12 at 15:57
  • 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. – Thomas Andrews Jan 17 '12 at 20:03
  • See also http://math.stackexchange.com/questions/461331/prove-p-kk-1-equiv-1k-text-mod-p. – lhf Oct 03 '13 at 01:14

2 Answers2

7

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

JavaMan
  • 13,375
Robert Israel
  • 470,583
  • For example: $(p-4)!\equiv (3!)^{-1}\mod p$. ** what is** $(3!)^{-1}\mod p$? Is it is equal to $(6\mod p)^{-1}$ that is multiplicative inverse of $6$ in $\mathbb{Z}_p$ ? – Akash Patalwanshi Sep 11 '21 at 15:50
  • Sir, I thing something wrong with the formula. By above closed form formula: $98!\equiv (-1)^2 (2!)^{-1}\mod 101$ that is $98!\equiv (2)^{-1}\mod 101$ that implies $98!\equiv 51\mod 101$. However this is not true! Since $98!\equiv 50\mod 101$ – Akash Patalwanshi Sep 12 '21 at 13:24
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...

lhf
  • 221,500