# Why is $Z^{p}-Z$ is always a multiple of $p$, Where $p$ is a prime, and $Z$ is a positive integer?

I came upon the conclusion that $Z^{p}-Z$ is always a multiple of $p$. $\$Where $p$ is a prime, and $Z$ is a positive integer.

I have the following four questions:
a) Could someone provide a complete proof for the above statement?
b) If any counter examples can be found?
c) If this can be easily derived from properties of Mersenne primes in the case $Z=2$?
d) If this indeed true, does it already have a name, wikipedia page, etc... (I have failed to find mention of this fact (if it is true), but I would like to be directed to where I may learn more, if it is well known)

I have tested this with approxamitely 80 sets of numbers and it seems to hold up.

I have found a partial, and flawed proof, but it explains some cases. I originally started thinking about this problem when I realized that because 7 may be expressed as a repeating decimal with six repeating digits, the following must be true: $$\frac 1 7 * \frac n n = \frac n {{10}^6-1}$$ (because $\overline {0.000001} = \frac 1 {{10}^6-1}$, in this case $n = 142857$). $\$Hence, ${{10}^6-1}$ is a multiple of 7. $\$Since $10*({{10}^6-1})$ is still a multiple of seven, ${{10}^7-10}$ must clearly be a multiple of $7$, conforming with the original formula. I first tested the previously mentioned equation on the assumption that these steps should hold true in every base. $\$However, this would seem to apply only to numbers with $7$'s property of repeating every $n-1$ digits, and it would have to indeed hold true across bases. I hope a fuller expanation may be provided.

• In case you were unaware: en.wikipedia.org/wiki/Fermat%27s_little_theorem – Cameron Williams Mar 3 '16 at 3:52
• In fact, if $p$ is prime, then $p\mid z^p-z$ for any integer $z$ (not only positive integer). – user236182 Mar 3 '16 at 3:59
• There is a connection with Mersenne primes, since Fermat found the result while trying to narrow the possibilities for divisors of $2^p-1$. – André Nicolas Mar 3 '16 at 4:07

## 1 Answer

This is known as Fermat's Little Theorem. There are many proofs. Here are some, all on Math.SE.

1. Dirichlet's elementary proof.
2. An application of induction and the binomial theorem.
3. An application of Lagrange's Theorem from group theory.
4. A proof using the existence of primitive roots.

You ask if this can be determined from properties of Mersenne primes. In fact, the history of Fermat's Little Theorem and Mersenne primes are intertwined, and some have tried to use Fermat's Little Theorem to better understand Mersenne primes.

In fact, the reason why the largest prime we know is always a Mersenne prime is due to the quick running time of the Lucas-Lehmer primality test, which uses ideas very related to Fermat's Little Theorem. See for instance this post of Terry Tao's for some description of the relations.