Closed form for $(p-4)!$ and $(p-3)!$ via Wilson's Theorem I would like to use Wilson's Theorem to compute
$(p - 4)! \mod p$
I've gotten as far as
$(p - 4)! \cdot (p-3) \cdot (p-2) \cdot (p-1) \equiv (p - 1) \pmod p$
However I can't figure out how to isolate
$(p - 4)! \mod p$
 A: By Wilson reflection $\rm\ mod\ p\!:\: -1 \equiv (p\!-\!1)! = \overbrace{(p\!-\!1)(p\!-\!2)(p\!-\!3)(p\!-\!4)!}^{\textstyle \equiv (-1)\ (-2)\ (-3)\ (p\!-\!4)!}\equiv -6(p\!-\!4)!$
But for $\rm\:p \ne 2,3,\: \ \ 2\cdot 3 = 6\:$ will be invertible mod $\rm\:p,\:$ so $\rm\:(p-4)! \equiv 1/6\pmod p$
Furthermore, notice $\rm\ \ p = 6\:k\pm 1\:\Rightarrow\:\bbox[5px,border:1px solid #c00]{(p\!-\!4)!\,\equiv\, 1/6\, \equiv  (1\mp p)/6},\, $ where $\rm\,6\mid 1\mp p$
Similarly $\,-1 \equiv (p\!-\!1)! = 2(p\!-\!3)! \Rightarrow \bbox[5px,border:1px solid #c00]{\rm(p\!-\!3)! \equiv -1/2 \equiv (p\!-\!1)/2},\,$ where $\rm\,2\mid p\!-\!1$
Note $\:$ The signed-equation denotes two equations: the top sign case, and bottom sign case.
$$\begin{eqnarray}\rm\:p = 6\:\!k{\color{#c00}{+1}}\: &\Rightarrow& \rm\:(p-4)!\equiv 1/6\equiv (1+{\color{#c00}{(-1)}} p)/6&\rm\quad top\ signs \\ 
\rm\:p = 6\:\!k{\color{#c00}{-1}}\: &\Rightarrow &\rm\:(p-4)!\equiv 1/6\equiv (1+{\color{#c00}{(+1)}} p)/6&\rm\quad bottom\ signs \end{eqnarray}$$
Indeed, we seek $\rm\:x\:$ so $\rm\:6\:|\:1+x\:\!p,\:$ or $\rm\:mod\ 6\!:\: -1\equiv x\:\!p \equiv x\!\:s,\:$ where $\rm\:\color{#c00}s = (p\ mod\ 6),\,$ by inverse reciprocity. So $\rm\:x \equiv -1/s.\:$ Here $\rm\:s\equiv \pm1\:\Rightarrow\:s^2 = 1\:\Rightarrow\: -1/s = -s/s^2 = -s,\:$ so
$$\rm\:p = 6\:\!k+{\color{#c00}{s}}\: \Rightarrow\: (p-4)!\equiv 1/6\equiv (1+{\color{#c00}{(-s)}}\:\! p)/6\quad abstract\ sign$$
Hence the equation that I wrote above involving the signs $\pm$ and $\mp,$ denotes two equations, the case $\rm\:s = 1\:$ of above (choose all the top signs) and case $\rm\:s = -1\:$ (choose all the bottom signs). Indeed, if we substitute $\rm\: s = \pm 1\:$ then $\rm -s = \mp 1,\:$ so we obtain said equation with signs.
Such expressions can be given a rigorous algebraic interpretation by working in certain quotient rings,$\:\!$ i.e.  modulo $\rm\:s^2 = 1.\:$ Namely $\rm\:R[s]/(s^2-1) \cong R[s]/(s-1) + R[s]/(s+1)\cong R^2.\:$ Hence arithmetic in $\rm\:R\:$ with adjoined sign $\rm\:s\:$ is isomorphic to arithmetic of pairs of elements of $\rm\:R,\:$ where the first component denotes the universe where $\rm\:s = 1\:$ and the second where $\rm\:s = -1.\:$
Beware, however, that sometimes such signed expressions denote the set of equations resulting from all possible combinations of signs. In this case one adjoins multiple sign indeterminates $\rm\:s_i\:$ such that $\rm\:s_i^2 = 1.\:$ One often needs to infer from the context which denotation is intended.
A: You can use the facts that $p-k \equiv -k \mod p$. Then you have to decide whether the product is invertible.
