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

Find the remainder when $ 12!^{14!} +1 $ is divided by $13$

I faced this problem in one of my recent exam. It is reminiscent of Wilson's theorem. So, I was convinced that $12! \equiv -1 \pmod {13} $ after this I did some test on the exponent and it seems like $12!^{n!} +1\equiv 2\pmod {13}\forall n \in \mathbb{N}$.

After I came back home I ran some more test and I noticed that if $p$ is prime then $(p-1)!^{n!} +1\equiv 2\pmod {p}\forall n \in \mathbb{N}$.

I was wondering if this result is true, if yes how to prove it? If not what is the formal way for solving the mother problem.

share|cite|improve this question
$12!^{n!} +1\equiv 0\pmod {13}$ and $(p-1)!^{n!} +1\equiv 2\pmod {p}$ for $n=1$ (or $0$) – Henry Jun 7 '12 at 6:47
Note that the original problem can also be solved by Fermat's little theorem: $12!^{12} \equiv 1 \pmod{13}$. – Peter Taylor Jun 7 '12 at 9:18
Note that your 'for all' quantifier needs the caveat that $n\gt 1$; if $n=1$ then the sums are $0\bmod p$, not $2$. – Steven Stadnicki Jun 7 '12 at 15:07
up vote 7 down vote accepted

By Wilson's Theorem, $12!\equiv -1\pmod{13}$. So for any non-negative even integer $m$, $(12!)^m+1\equiv (-1)^m+1\equiv 2\pmod{13}$. Since $0\le 2\lt 13$, it follows that $2$ is the remainder when $(12!)^m+1$ is divided by $13$.

If $m$ is odd, the same reasoning shows that $(12!)^m+1\equiv 0\pmod{13}$.

And $13$ is not particularly lucky or unlucky. The same result, with the same proof, holds if $13$ is replaced by any odd prime $p$, and $12$ is replaced by $p-1$.

The prime $2$ is slightly different. Whether $m$ is odd or even, $(1)^m +1\equiv 2\pmod{2}$, but the remainder is $0$, not $2$.

share|cite|improve this answer
... and $14!$ is even ... – Robert Israel Jun 7 '12 at 6:44
Aha that helps! Thanks a lot Andre :) – Quixotic Jun 7 '12 at 6:50

Hint $\ $ Unifying little Fermat and Wilson: $\rm C\:\!!^{\:\!C}\!\equiv 1\ mod\:\ C\!+\!1\:$ prime. Take your pick for a proof.

share|cite|improve this answer

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.