How can I prove that $n^7 - n$ is divisible by $42$ for any integer $n$?

Problems like this appear frequently here. There are a couple of standard approaches. One is to use Fermat's little theorem, which says that if $p$ is a prime number, then $n^p-n$ is divisible by $p$ for all $n$.

Since $42=2\times 3\times 7$, what we need to do is to check that 2, 3, and 7 divide $n^7-n$, no matter what $n$ is.

That 7 does is direct from Fermat's little theorem.

The theorem also ensures that 3 divides $n^3-n$. Now: $$n^7-n=n(n^6-1)=n((n^2)^3-1)=n(n^2-1)(n^4+n^2+1)=(n^3-n)(n^4+n^2+1),$$ so 3 indeed divides $n^7-n$.

Finally, $n$ and $n^7$ always have the same parity, so $n^7-n$ is even.


We can actually argue without Fermat's little theorem in this case. An approach that only requires patience is as follows: The idea is to factor the polynomial $x^7-x$ and then analyze the result when $x=n$ is an integer. (This is a trick that Bill Dubuque suggests sometimes in his solutions.)

We have: $x^7-x=x(x^6-1)=x(x^3+1)(x^3-1)=x(x+1)(x^2-x+1)(x-1)(x^2+x+1)$. When $x=n$, we have $$ n^7-n=(n-1)n(n+1)(n^2-n+1)(n^2+n+1). $$ Now we analyze this prime by prime, as before. Note that one of $n$ and $n-1$ is always even, so the product is even. Also, of 3 consecutive numbers, such as $n-1,n,n+1$, one is always divisible by 3, so it only remains to verify divisibility by 7.

We may assume that $n=7k+b$ where $b=\pm2$ or $\pm3$, since otherwise $(n-1)n(n+1)$ is a multiple of 7. In that case, $n^2\equiv 4$ or $2\pmod 7$, and one of $n^2+n$, $n^2-n$ is $\equiv 6\pmod 7$, so $(n^2-n+1)(n^2+n+1)$ is a multiple of 7.

The disadvantage of this approach over the previous one, of course, is the need to analyze different cases. Fermat's little theorem allows us to analyze all cases simultaneously, which typically (as here) results in a much faster approach.


If you are comfortable with the method of induction, this gives us a way of verifying divisibility by 7 which is not without some elegance (divisibility by 2 and 3 is probably best approached as before). Note that $(-n)^7-(-n)=-(n^7-n)$, so we may as well assume that $n\ge 0$. If $n=0$ it is obvious that 7 divides $n^7-n$.

Suppose then that $7|n^7-n$, and argue that $7|(n+1)^7-(n+1)$. For this, actually expand $(n+1)^7$ using the binomial theorem: $$ (n+1)^7=n^7+7n^6+{7\choose 2}n^5+{7\choose 3}n^4+\dots+1.$$ The point is that $${7\choose k}=\frac{7!}{k!(7-k)!}$$ is obviously divisible by 7 as long as $k\ne0,7$, so (modulo 7) we have that $(n+1)^7-(n+1)\equiv (n^7+1)-(n+1)=(n^7-n)$. Now we invoke the induction hypothesis, that precisely says that the latter is divisible by 7, and we are done.

Of course, exactly the same inductive argument gives us a proof of Fermat's little theorem: $p|n^p-n$ for any $p$ prime and any integer $n$.


It is a special case of the following global-form of little Fermat. $ $ For $\rm\, a,k,n\in\mathbb N$ with $\rm\ a,k > 1$

$\rm\qquad d\ |\ n^k\! -\! n\ $ for all $\rm\:n\:$ $\rm \iff\ d\:$ is squarefree, and $\rm\ p\!-\!1\ |\ k\!-\!1\ $ for all primes $\rm\:p\:|\:d$

Hence for $\rm\: a = 42 = 2\cdot 3\cdot 7\ $ we deduce: $\rm\ \ 42\ |\ n^k\!-n\ $ for all $\rm\:n \iff 6\ |\ k\!-\!1$

For the simple proof and further discussion see Korselt's criterion for Carmichael numbers here (or my 2009/04/10 sci.math post, link is now broken by google)

Here is another useful variation:

Theorem $\ \ \ n^{\large k+\phi}\equiv n^{\large k}\pmod{p^i q^j}\ \ $ assuming that $ \ \color{#0a0}{\phi(p^i),\phi(q^j)\mid \phi},\, $ $\, i,j \le k,\,\ p\ne q.\ \ \ $

Proof $\ \, p\nmid n\,\Rightarrow\, {\rm mod\ }p^i\!:\ n^{ \phi}\equiv 1\,\Rightarrow\, n^{k + \phi}\equiv n^k,\, $ by $\ n^{\Large \color{#0a0}\phi} = (n^{\color{#0a0}{\Large \phi(p^{ i})}})^{\large \color{#0a0}m}\!\overset{\color{blue}{\rm (E)}}\equiv\! 1^{\large m}\!\equiv\! 1$ by $\rm\color{blue}{E}$=Euler

$\qquad\quad\ \, \color{#c00}{p\mid n}\,\Rightarrow\, {\rm mod\ }p^i\!:\ n^k\equiv 0\,\equiv\, n^{k + \phi}\ $ by $\ n^k = n^{k-i} \color{#c00}n^i = n^{k-i} (\color{#c00}{mp})^i$ and $\,k\ge i.$

So $\ p^i\mid n^{k+\phi}\!-n^k.\,$ By symmetry $\,q^j$ divides it too, so their lcm $ = p^iq^j\,$ divides it too. $\ $ QED

Remark $\ $ Obviously the proof immediately extends to an arbitrary number of primes. This leads the way to Carmichael's Lambda function, a generalization of Euler's phi function.


There are many equivalent ways of proving it.

First observe that $42$ divides a number iff $2,3$ and $7$ divides the number.

(Since $42 = 2 \times 3 \times 7$ and $\gcd(2,3) = \gcd(3,7) = \gcd(2,7) = 1$)

Divisibility by $2$:

Clearly, $2|(n^7-n)$ since $n^7$ and $n$ are of the same parity.

Equivalently you could argue out that $2|(n^2-n)$ directly from Fermat's little Theorem. (This is an overkill of Fermat's Little Theorem.)

Divisibility by $3$:

$n^7-n = n(n^6-1) = n(n^2-1)(n^4+n^2+1)=n(n+1)(n-1)(n^4+n^2+1)$.

$3|n$ or $3|(n-1)$ or $3|(n+1)$ and hence $3|(n^7-n)$.

Equivalently you could argue out that $3|(n^3-n)$ directly from Fermat's little Theorem.

Divisibility by $7$:

Note that $n$ can be either $7k$ or $7k \pm 1$ or $7k \pm 2$ or $7k \pm 3$.

If $n=7k$ or $n=7k \pm 1$, we are again done since then $7|n$ or $7|(n+1)$ or $7|(n-1)$ and hence $7|(n^7-n)$.

If $n=7k \pm 2$, then $n^2 = (7k \pm 2)^2 = 7m + 4$ and $n^4 = (7m+4)^2 = 7l+2$. Hence $n^4 + n^2 + 1 = 7l+2 + 7m + 4 + 1 = 7(l+m+1)$ and hence $7|(n^4 + n^2 + 1) \Rightarrow 7|(n^7-n)$.

If $n=7k \pm 3$, then $n^2 = (7k \pm 3)^2 = 7m + 2$ and $n^4 = (7m+2)^2 = 7l+4$. Hence $n^4 + n^2 + 1 = 7l+4 + 7m + 2 + 1 = 7(l+m+1)$ and hence $7|(n^4 + n^2 + 1) \Rightarrow 7|(n^7-n)$.

Hence, $7|(n^7-n)$.

Equivalently you could argue out that $7|(n^7-n)$ directly from Fermat's little Theorem.

Therefore, we have that $2|(n^7-n)$ and $3|(n^7-n)$ and $7|(n^7-n)$, $\forall n \in \mathbb{N}$.

Hence, $42|(n^7-n)$, $\forall n \in \mathbb{N}$.