Call Us 07766496223
If  
\[p\]
  is an odd prime and  
\[gcd(a,p)=1\]
  then  
\[(p-1)! \equiv -(a/p)a^{p-1} \; (mod \; p)\]
.
By a property of the Legendre symbol,  
\[(a/p) \equiv a^{\frac{p-1}{2}} \; (mod \; p)\]
. Hence  
\[(a/p)a^{\frac{p-1}{2}} \equiv (a/p)(a/p) \equiv 1 \; (mod \; p)\]
. From Wilson's Theorem  
\[(p-1)! \equiv -1 \; (mod \; p)\]
  so  
\[(p-1)! \equiv -(a/p)a^{p-1} \; (mod \; p)\]
.