Show that $(27!)^6 \equiv 1 \pmod{899}$ Show: $(27!)^6 \equiv 1 \pmod{899}$. Note: $899=30^2 - 1$.
Could anyone show me how to go through this please?  I think I have to use Wilson's theorem which is $(p-1)! \equiv -1 \pmod p$ but not exactly sure how else to tackle this.  Thanks!

Using Wilson's Theorem,  $28!\equiv-1\pmod{29}\implies 27!(28)\equiv-1$
$\implies 27!(-1)\equiv-1\implies 27!\equiv1\pmod {29}$
$\implies (27!)^6\equiv 1\pmod{29}$
Again $30!\equiv-1\pmod{31} \implies 27!(28)(29)(30)\equiv-1$
$\implies 27!(-3)(-2)(-1)\equiv-1\implies 27!(6)\equiv1 \implies 27!(30)\equiv5$ (multiplying either sides by $5$)
$\implies 27!(-1)\equiv5\implies 27!\equiv-5\pmod{31}$
So,$(27!)^6\equiv 5^6\pmod{31}$
Now, $5^3=125\equiv1\pmod{31} \implies (27!)^3\equiv -1\pmod{31}$
$\implies (27!)^6\equiv (-1)^2\pmod{31}\equiv1$
So, lcm$(31,29)\mid \{(27!)^6-1\}$ but lcm$(31,29)=31\cdot 29=899$
