Given $n$ is a positive odd integer what is the fastest way to compute $\left(\frac{n-1}{2}\right)!\pmod{n}$ ?
I've observed that:
$2 \cdot \left(\frac{n-1}{2}\right) \equiv -1 \pmod{n}$
$3 \cdot \left(\frac{n-1}{2} - 1\right) \equiv \frac{3n-9}{2} \pmod{n}$
$4 \cdot \left(\frac{n-1}{2} - 2\right) \equiv -10 \pmod{n}$
And therefore:
$2 \cdot 3 \cdot 4 \cdot \left(\frac{n-1}{2}\right) \cdot \left(\frac{n-1}{2} - 1\right) \cdot \left(\frac{n-1}{2} - 2\right) \equiv (-1) \cdot \left(\frac{3n-9}{2}\right) \cdot (-10) \equiv -45 \pmod{n}$
So this reduces the number of multiplications needed by $5$ and it can be reduced even more if we continue multiplying the numbers like that. But I don't know how to get a formula from it. Is it possible at all?