Take the 2-minute tour ×
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.

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

share|improve this question
    
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. –  Nikhil Bellarykar 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 math.stackexchange.com/questions/461331/…. –  lhf Oct 3 '13 at 1:14

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer

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

share|improve this answer
1  
You can write the inverse of $p-3$ as $\frac{p^2-1}3$ if you want to eliminate the $\pm 1$. –  Thomas Andrews Jan 17 '12 at 17:29
    
@ThomasAndrews, good point. –  lhf Jan 17 '12 at 19:57
1  
See also this answer. –  Bill Dubuque May 12 at 22:37

Your Answer

 
discard

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.