Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

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

Fermat's little theorem

$a^{p} \equiv a\pmod p$ if p prime

I have noticed that the formula $a^{p} \equiv a\pmod {2p}$ (p prime and p>2) can be also written by using Fermat's little theorem

Proof: Let $a$ be any integer and $p>2$ be some prime number.

$a^{p} \equiv a\pmod p$

$a^{p}-a \equiv 0\pmod p$

$a(a^{p-1}-1) \equiv 0\pmod p$

$a(a^{p-1}-1) \equiv 0\pmod p$

$F(a)=(a^{p-1}-1)$ can be divided to $(a-1)$ because $F(1)=(1^{p-1}-1)=0$

$F(a)=(a^{p-1}-1)=(a-1).R(a)$ //R(a) is polinom that has degree p-2 and coefficients are Integer numbers.

$a (a-1) R(a) \equiv 0\pmod p$

$a (a-1)$ is always an even number so $a (a-1) R(a)$ will be always even number and also can be divided to $p$ because of Fermat's little theorem . Thus $a^{p} \equiv a\pmod {2p}$ if (p prime and p>2) .

I searched internet but I have not seen that relation in the internet.

Is it known formula?Please help if it is known relation(I would like to learn what the subject is )

Sorry if someone else asked the same question in here.

Thank you for answers and helps.

share|cite|improve this question
If $a$ is any integer, and $n$ a positive integer, then $a^n \equiv a \mod 2$. Your equation is a combination of this fact and Fermat's little theorem. Both are known congruences, but I'm note sure there's a name for their combination. – Joel Cohen Feb 4 '12 at 14:49
up vote 1 down vote accepted

As Joel rightly observed :If $a$ is any integer, and $n$ a positive integer, then $a^n\equiv a \pmod2$

So : $a^p\equiv a \pmod2$ , and $a^p\equiv a \pmod p$

According to Chinese Remainder Theorem :

$a^p \equiv a \pmod { \operatorname{lcm} (2,p)} $

,and since $p$ is an odd prime it follows that : $\operatorname{lcm}(2,p) = 2p$ , therefore :

$a^p \equiv a \pmod {2p}$

share|cite|improve this answer
The answer, Maybe, can be perfect and if we add some additional steps to show how proof of Chinese Remainder Theorem. c,d,e are integers if $a^p\equiv a \pmod2$ then $a^p=a+2.c$ $a^p-a=2.c$ if $a^p\equiv a \pmod p$ then $a^p=a+p.d$ $a^p-a=p.d=2.c$ $d=2.e$ can be written because $2.c$ is even number Thus $a^p-a=p.d=2.c=2.p.e$ $a^p-a\equiv 0 \pmod{2p}$ $a^p\equiv a \pmod{2p}$ Thanks in advice – Mathlover Feb 4 '12 at 19:32

You are correct I think, but the way you write it down makes it look more difficult than it is. Also you should be more specific on whether you are talking about one particular $a$ or "$\forall a$".

So let me show how I would write this down. First, let $a$ be any integer and $p>2$ be some prime number. Then

$$ a^p \equiv a \pmod{2p} \iff 2p \mid a^p - a \iff 2\mid a^{p}-a \text{ and } p\mid a^p-a$$ The last equivalence holds because $2$ and $p$ are two different primes.

But $2\mid a^p-a$ for all $a$ and $p$: if $a$ is even, then clearly $a^p$ will be even as well; if $a$ is odd, then so is $a^p$ and hence $a^p-a$ will be even again. So this is indeed equivalent to

$$\dots \iff p\mid a^p-a \iff a^p \equiv a \pmod p.$$

share|cite|improve this answer
Thanks for answer. – Mathlover Feb 4 '12 at 14:46
No actually it's a continuation of the chain of equivalences up above. So it should be read as $$ a^p \equiv a \pmod{2p} \iff \dots \iff a^p\equiv a \pmod{p}$$ – Myself Feb 4 '12 at 14:51

This is the special case $\rm\ m = 2\:p,\ p\:$ odd, of the following generalization of Fermat's little theorem, quoted from Bill Dubuque's post

THEOREM $\ $ For naturals $\rm\: k,m>1 $

$\qquad\rm m\ |\ a^k-a\ $ for all $\rm\:a\in\mathbb N\ \iff\ m\:$ is squarefree and prime $\rm\: p\:|\:m\: \Rightarrow\: p-1\ |\ k-1 $

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.