We are given $n, m \in \mathbb{N}$ and $a$ an integer greater than or equal to 1. Calculate $\left(a^{n}-1, a^{m}-1\right)$.
We can assume $n \geqslant m$. Write $n=m q+r$ with $0 \leqslant r<m$ the Euclidean division of $n$ by $m$. Then $a^{m}-1$ divides $a^{m q}-1$ since $a^{m q}-1=\left(a^{m}-1\right)\left(1+a^{m}+\cdots+a^{m(q-1)}\right)$, so

$$
\begin{aligned}
\left(a^{n}-1, a^{m}-1\right) & =\left(a^{r}\left(a^{m q}-1\right)+a^{r}-1, a^{m}-1\right) \\
& =\left(a^{r}-1, a^{m}-1\right)
\end{aligned}
$$

According to the Euclidean algorithm,

$$
\left(a^{n}-1, a^{m}-1\right)=\left(a^{(n, m)}-1, a^{0}-1\right)=a^{(n, m)}-1
$$