g.c.d.{$m^p-m:m=2$ to $n$} $= ?$ Let $p$ be an odd prime and $n&gt;2$ is an integer , then what is the $g.c.d.$ of the numbers
{$m^p-m:m=2$ to $n$} ? (by Fermat's little theorem it is easy to see , $2p$ divides the g.c.d. , but I can not proceed further)
Let me expand on benh's answer, which somewhat answers the question for sufficiently large $m$. In particular, we have an exact answer when we set $m\geq \lceil \sqrt p\rceil$. I have yet to consider the case when $n&gt;\lceil \sqrt p\rceil$, although it should be similar.  

Let $D$ be the GCD that we seek.  

Our first goal is reduce the types of $m$ we need to test.


1. It suffices to consider $m^p-m$ for prime $m$  

Suppose we have $q$ any prime and $n$ any integer such that
$$D|q^p-q$$
$$D|n^p-n$$
Then
\begin{align*}
(qn)^p-(qn) &amp;= q^p(n^p)-q^p(n)+q^p(n)-(qn)\\
&amp;=q^p(n^p-n)+n(q^p-q)
\end{align*}
Since $D$ divides $n^p-n$ and $q^p-q$, $D$ divides $q^p(n^p-n)+n(q^p-q)=(qn)^p-(qn)$.  

This shows that it suffices to compute $D$ from all $m$ that are prime. Let us denote
$$S_B=\{p\leq B\;|\;p\text{ is prime}\}$$

2. $D$ is squarefree if $B=\lceil\sqrt{p}\rceil$  

Let $D$ be obtained from GCDs of $m^p-m$ with $m\in S_B$. Suppose we have some $q|D$. We are interested in whether $q^2|D$. Suppose it does, then we know that
$$q^2|D, D|m^p-m$$
therefore
$$q^2|m^p-m\Longleftrightarrow m^p-m\equiv 0\pmod{q^2}$$
However, suppose we have $q\in S_B$. Then when we test GCD with $m=q$, we have
$$m^p-m=q^p-q=q^2q^{p-2}-q\equiv 0-q\equiv q^2-q\pmod{q^2}$$
which is not $0$. We restate this as follows:


  $\textbf{Proposition.}$ Let $q\in S_B$ and let $D=\gcd(m^p-m\;|\;m\in S_B)$. Then $q^2\nmid D$.


From benh's answer, we know that for any $q|D$, we must have
$$(q-1)|(p-1)$$
from which we can deduce
$$q-1\leq \sqrt {p-1}$$
$$q\leq \sqrt {p-1}+1&lt;\sqrt p + 1$$
$$q\leq \lceil \sqrt p\rceil$$

Therefore if we set $B=\lceil \sqrt p\rceil$, then any prime $q|D$ must lie in $S_B$. Now by our proposition above we must have $q^2\nmid D$. This shows that $D$ is squarefree.


3. Primes $l&gt;p$ does not reduce $D$  

Now we consider what happens when we take gcd of $D$ with some prime $l&gt;\lceil \sqrt p\rceil$. Recall that we are not concerned with composite $&gt;p$, since they are always divisible by $D$ by section 1. Suppose we have some integer $q$ such that $q|D$. Then since $D$ is squarefree, $q$ is in fact a prime.  

We observe that
\begin{align*}
l^p-l &amp;\equiv (l-q)^p-(l-q)\pmod {q}\\
&amp;\equiv (l-2q)^p-(l-2q)\pmod {q}\\
&amp;\dots\\
&amp;\equiv (l-kq)^p-(l-kq)\pmod {q}
\end{align*}
So that $q|l^p-l$ if and only if $q|(l-kq)^p-(l-kq)$, i.e. when $m=l-kq$, for any integer $k$. But this means we can scale $m=l-kq$ such that $m\leq B$, which we then know that $q|m^p-m$.  

Therefore in fact $q|l^p-l$ for any $l&gt;\lceil \sqrt p\rceil$. By consider prime by prime, this shows that in fact $D|l^p-l$. Therefore $D$ does not change when taking GCD with $l&gt;\lceil \sqrt p\rceil$.

4. Exact answer when $B=\lceil \sqrt p\rceil$  

We summarize the results so far:
(1) We can find the minimum GCD $D$ by taking $B=\lceil \sqrt p\rceil$ and setting
$$D=\gcd(m^p-m\;|\;m\in S_B)$$
taking GCD with larger $m$ does not change the result.  

(2) Every prime factor $q$ of $D$ satisfies
$$(q-1)|(p-1)$$
$$q^2\nmid D$$

Therefore, to find $D$, it suffices to consider all divisors of $p-1$:
$$T=\{x\in\Bbb N\;|\; x|p-1\}$$
If $e\in T$ and $e+1$ is prime, then $e|D$. We can check this 1 by 1, through the list $T$.
(This is the same function as in benh's.)

5. Example  

Let $p=7919$, the $1000$-th prime. We have the factorization
$$p-1=2 \cdot 37 \cdot 107$$
so that our set $T$, integers that divide $p-1$, is
$$T=\{1, 2, 37, 74, 107, 214, 3959, 7918\}$$
Note that $q-1\in T$, so we are interested in primes of $T+1$:
$$T+1=\{2, 3, 38, 75, 108, 215, 3960, 7919\}$$
The primes are
$$\{2,3,7191\}$$
Which tells us that
$$D=2\cdot 3\cdot 7191=47514$$

A computer check tells us that this is correct, along with all other primes $\leq 7191$.
There is only one case to consider i.e $n&lt;2p$, otherwise,Fermat's theorem breaks down. 
Consider the first two consecutive terms of the set;
from Fermat's theorem, 
$m^p-m=kp$ and $(m+1)^p-(m+1)=k'p$, divide the two equations to get;
$(m^p-m)k'={(m+1)^p-(m+1)}k$, now either $(m^p-m)|{(m+1)^p-(m+1)} or $(m^p-m)|k$. 
Case 1: $(m^p-m)|{(m+1)^p-(m+1)},
it follows that 
$m(m^(p-1)-1)|(m+1){(m+1)^(p-1)-1}, now m does not divide m+1, else m=1, a contradiction, further, if ${m^(p-1)-1}|{(m+1)^(p-1)-1}, then $m|(m+1)$, again a contradiction showing that case 1 does not hold afterall
case 2:  $(m^p-m)|k$
but since  $(m^p-m)=kp$, it follows that either $k|(m^p-m)$ in which case k=1, or k is a multiple of (m^p-m) showing that $p=1$ a contradiction. 
the same argument follows for other consecutive values of the given set. Hence, the required $gcd=p$