# $N! \pmod{P}$ (huge numbers)

What is the value of $$2019! \pmod{7}$$?

I guess it's $$0$$? Because $$2019! = 2019\cdot2018\cdot2017\cdot ...\cdot7\cdot6\cdot...\cdot1$$ There's $$7$$ and also numbers that has $$0$$ remainder when divided by $$7$$, times the other numbers equals $$0$$.

Can someone correct me if I'm wrong? I'm still not sure this is the answer though. Thanks

• All good. $2019!$ is zero mod $n$ for any $n \le 2019$ (and many more numbers besides). – TonyK Feb 14 at 13:35
• Well you are right, by definition x=0 mod (m) iff x = k*m for some k. Since as you said 2019! = 7*k , then is 0 mod 7 – JoseSquare Feb 14 at 13:35
• Correct, the answer is 0. This is simply because $2019!$ is a multiple of $7$. – Minus One-Twelfth Feb 14 at 13:36
• Thanks for your help guys! – Godlixe Feb 14 at 13:45
• The follow-up question of how many powers of 7 are in 2019! is a classic question that you may enjoy. – Jim Ferry Feb 14 at 15:46

Yes, $$2019! = 1 \times 2 \times 3 \times 4 \times 5 \times 6 \times 7 \times 8 \times 9 \times ... \times 2019$$ $$=7 \times (1 \times 2 \times 3 \times 4 \times 5 \times 6 \times 8 \times 9 \times ... \times 2019),$$ so $$2019!$$ is a multiple of $$7$$ and the remainder when $$2019!$$ is divided by $$7$$ is $$0,$$ and therefore we write $$2019! \equiv 0 \pmod 7.$$
Note that we do not need to compute $$2019!$$ -- a number with thousands of digits -- to make this determination.
As pointed out in the comments, indeed all natural numbers up to and including $$2019$$ divide $$2019!,$$ by a similar argument. Also, $$7$$ divides $$2019!$$ many times (exactly how many is a different question) because of the factors $$14, 21, 28, ...$$ in $$2019!.$$