# Modulo of factorial [duplicate]

How do I solve for M modulo 2021 where M is the product of all numbers relatively prime to 2021 that are less than 2021. I know Wilson's Theorem but that's applicable for modulo p where p is prime. Should I use CRT by breaking 2021 into 43 and 47 but even that seems intractable to me. Any help is appreciated.

• $2020!$ has several factors of $43$ and $47$ – lulu Jan 25 at 15:10
• Of course the remainder is $0$. What makes you think otherwise? – lulu Jan 25 at 15:18
• Yes it is the case why do you think it isnt? – Archis Welankar Jan 25 at 15:19
• I have edited the problem as I spotted a mistake in definition of M – Mathronza Jan 25 at 15:25

All of these numbers will have multiplicative inverses (mod 2021), so they all cancel, with the exception of those numbers which are their own inverses. So $$M$$ is the product of the residues whose square is $$1$$.
We can find all such $$x$$ using the CRT to be $$1, 988, 1033, 2020$$. So their product $$M = 1$$.