Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know the smallest $x \in \mathbb{N}$, satisfying $1! + 2! + \cdots + 20! \equiv x\pmod7$ is $5$. I would like to know methods to get to the answer.

share|cite|improve this question
One natural question, I think, is to find the remainder when $1! + 2! + \cdots + (n-1)!$ is divided by $n$. This is . The problem of when this is zero is apparently of at least minor interest, according to Guy, Unsolved Problems in Number Theory: – Michael Lugo Dec 14 '11 at 1:49
up vote 8 down vote accepted

Note that each of $7!$, $8!$, $9!,\ldots, 20!$ is congruent to $0$ modulo $7$, since they are all divisible by $7$.

Note that $6!\equiv -1\pmod{7}$ by Wilson's Theorem, which cancels $1!$.

That leaves $2!+3!+4!+5! = 2! + 3!(1 + 4 + 20)$. But $3!\equiv -1\pmod{7}$, and $20\equiv -1\pmod{7}$, so $2!+3!+4!+5! \equiv 2-(1+4-1) = -2\equiv 5\pmod{7}$.

share|cite|improve this answer
It is implicit in Arturo's answer, but it is interesting to note that $1! + 2! + \cdots + n! \equiv 5$ for any $n \geq 7$. – Austin Mohr Dec 13 '11 at 22:11
+1,The problem could be solved without Wilson's theorem but it always handy to know and use these tools. – Quixotic Dec 13 '11 at 22:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.