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 that if $p$ prime and $p\nmid a$, then $a^{p-1}\equiv 1\pmod p$ and I know also that $a^{p}\equiv a \pmod p$ using the fact $a\equiv a \pmod p$ and multiplying the members.

What I couldn't understand is why in the Fermat little theorem we have $a^{p}\equiv a \pmod p$ for all integer $a$.

share|cite|improve this question
I don't understand your question properly. – rah4927 May 1 '14 at 5:40
If $p$ divides $a$ then both $a^p$ and $a$ are congruent to $0$. – André Nicolas May 1 '14 at 5:42
@AndréNicolas of course!!! thanks – user42912 May 1 '14 at 5:43
You already know the result for coprime p and a. If $p|a$ , $a^p\equiv 0\pmod p$ and since $0\equiv a\pmod p$, and the claim follows. – rah4927 May 1 '14 at 5:44
@user42912: You are welcome. Sometimes "too easy" can be hard to see, we look for something fancy. – André Nicolas May 1 '14 at 5:46

If $p$ divides $a$ then both $a^p$ and $a$ are congruent to $0$, so $a^p\equiv a\pmod{p}$ holds trivially.

Remark: From $a^p\equiv a\pmod{p}$, we can conversely derive the more common form of Fermat's Theorem. For if $a^p\equiv a\pmod p$, then $p$ divides $a(a^{p-1}-1)$. So if $p$ does not divide $a$, then $p$ divides $a^{p-1}-1$.

share|cite|improve this answer

Either $p$ divides $a$ or $p\nmid a$

As $p$ is prime $p\nmid a\implies (a,p)=1$

As $\displaystyle a^p-a=a(a^{p-1}-1)$

This will be divisible by $p$ if $p|a$

otherwise it will also be divisible by $p$ as $p|(a^{p-1}-1)$ by Fermat little theorem

share|cite|improve this answer
up vote 1 down vote accepted

Following the comments of André Nicholas:

If $p\mid a$, then $a\equiv 0 \pmod p$, then multiplying $p$ times both sides we have $a^p\equiv 0 \pmod p$. Thus we have $a\equiv 0 \pmod p$ and $0\equiv a^p\pmod p$ by symmetry, then finally by transitivity:

$$a\equiv a^p \pmod p$$

share|cite|improve this answer
I suppose you meant to say $ p\mid a$ in the second line? – awllower Nov 11 '14 at 14:08
@awllower thank you! – user42912 Feb 9 at 8:22

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.