25

Somewhere on Stack Exchange I saw the equation

$$\gcd(2^m-1,2^n-1)=2^{\gcd(m,n)}-1.$$

I had never seen this before, so I started trying to prove it. Without success...

Can anyone explain me (so actually prove) why this equation is true?

And can we say the same when replacing the '$2$' by any integer number '$a$'?

Bart Michels
  • 26,355

6 Answers6

29

In general, if $p=\gcd(m,n)$ then $p=mx+ny$ for some integers $x,y$.

Now, if $d = \gcd(2^m-1,2^n-1)$ then $2^m \equiv 1 \pmod d$ and $2^n \equiv 1\pmod d$ so $$2^p = 2^{mx+ny} = (2^m)^x(2^n)^y \equiv 1 \pmod d$$

So $d\mid 2^p-1$.

On the other hand, if $p\mid m$ then $2^p-1\mid 2^m-1$ so $2^p-1$ is a common factor.

And yes, you can replace $2$ with any $a$.

Thomas Andrews
  • 177,126
3

Yes, you can say the same when replacing $2$ with an integer $a \geqslant 2$.

Lemma. Suppose that $a \geqslant 2$, $m, n \in \mathbb{N}$ and $\gcd(m, n)=1$. Then $\gcd(a^m-1, a^n-1)=a-1$.

Proof. It is obvious that $(a-1) | \gcd(a^m-1, a^n-1)$. So, we only need to prove that $\gcd(a^m-1, a^n-1) | (a-1)$.

It is well known that if $\gcd(m, n)=1$, then there exist $k, l \in \mathbb{N}$ such that $mk-nl=1$. If is obvious that $(a^n-1)|(a^{nl}-1)$, therefore $$ \gcd(a^m-1, a^n-1) | (a^{nl}-1), $$ and for the same reason $$ \gcd(a^m-1, a^n-1) | (a^{mk}-1). $$

Now we just observe that $$ (a^{mk}-1)-a\cdot(a^{nl}-1) = (a^{nl+1}-1)-(a^{nl+1}-a) = a - 1, $$ therefore $$ \gcd(a^m-1, a^n-1) | (a-1), $$ QED.

Now we can prove the main statement: for $b \geqslant 2$ we have: $$ \gcd(b^m-1, b^n-1) = b^{\gcd(m,n)}-1. $$ Proof. Set $a = b^{\gcd(m, n)}$, $m'=m/\gcd(m,n)$ and $n'=n/\gcd(m,n)$. Clearly, $\gcd(m',n')=1$, and by the lemma we have $$ \gcd(a^{m'}-1,a^{n'}-1) = a-1, $$ which is exactly what we need, QED.

Dan Shved
  • 15,862
  • 39
  • 55
3

Hint $\rm\bmod d\!:\ a^{\large m}\!\equiv 1\equiv a^{\large n}\!\iff order(a)\mid m,n\iff order(a)\mid(m,n)\iff a^{\large (m,n)}\!\equiv 1$

Therefore $\rm\ \ d\mid a^{\large m}\!-1,\,a^{\large n}\!-1$ $\iff$ $\rm\:d\mid a^{\large (m,n)}\!-1,\ \,$ hence $\rm\,\ \ (a^{\large m}\!-1,\,a^{\large n}\!-1)\, =\, a^{\large (m,n)}-1$

Bill Dubuque
  • 272,048
Math Gems
  • 19,574
2

Suppose $x$, $m$ and $n$ are positive integers with $m$ and $n$ coprime. First let us show that $$r = 1 + x + {x^2} + \ldots + {x^{m - 1}}$$ and $$s = 1 + x + {x^2} + \ldots + {x^{n - 1}}$$ are relatively prime. If $d$ is a common divisor of $r$ and $s$, then $d$ is relatively prime to $x$ because $r$ and $s$ are one more than a multiple of $x$. Let $m$ be greater than $n$ (or vice versa) and consider $$r - s = {x^n} + {x^{n - 1}} + \ldots + {x^{m - 2}} + {x^{m - 1}} = {x^n}(1 + x + \ldots + {x^{m - n - 1}})$$ and notice that $d$ divides $r - s$ and so must be a divisor of $1 + x + \ldots + {x^{m - n - 1}}$. Observe that $m - n$ is relatively prime to both $m$ and $n$, so we can likewise use geometric sums which eventually becomes shorter and shorter until we conclude that $d$ must divide 1 i.e. $d = 1$. Now if we let $$d' = \gcd (m',n')$$ with $m' = md'$ and $n' = nd'$, then $m$ and $n$ are coprime and $${2^{m'}} - 1 = ({2^{d'}} - 1)(1 + {2^{d'}} + {2^{2d'}} + \cdots + {2^{(m - 1)d'}})$$ $${2^{n'}} - 1 = ({2^{d'}} - 1)(1 + {2^{d'}} + {2^{2d'}} + \cdots + {2^{(n - 1)d'}})$$ which are geometric sums with $x = {2^{d'}}$ and we showed that $\gcd (r,s) = 1$. This completes the proof.

glebovg
  • 10,154
  • "..., so we can likewise use geometric sum which eventually becomes shorter and shorter until we conclude that d must divide 1...". You may mean this: $d|\frac{x^{m-n}-1}{x-1}$. Let $a=m-n$, then we have $d|1+x+...+x^a$ and $d|1+x+...+x^n$, so we can repeat this over and over, letting $b=|n-a|$, ... Right? (Nice alternative solution, but I must confess I prefer Thomas' proof. Anyway, +1) – Bart Michels Oct 30 '12 at 16:39
0

Let $(m,n)=p$, then $p\mid m$, and $p\mid n$, then $m=m_1p$, $n=n_1p$, $(m_1,n_1)=1$, then $(2^{m_1p}-1,2^{n_1p}-1)=((2^{p})^{m_1}-1,(2^{p})^{n_1}-1)=((2^{p}-1)(.....),(2^{p}-1)(.....))=(2^{p}-1)$

Tao
  • 530
  • 2
  • 11
  • I don't understand the last step. Why can't $(...)$ and $(...)$ have a common divisor? (I do know what the dots mean) – Bart Michels Oct 30 '12 at 16:12
  • The dots are an unspecified polynomial, which is the remainder after factorising out $2^p-1$. They cannot have a common divisorsince otherwise $(m_1, n_1) \neq 0$ (i.e. we could factorise the power of 2 again). – Simon Hayward Oct 30 '12 at 16:15
  • So it is a polynomial of the form $2^{m_1}+(\text{lower order terms})$ – Simon Hayward Oct 30 '12 at 16:21
  • 1
    You've only shown that $2^p-1$ is a common factor, not the greatest common factor. – Thomas Andrews Oct 30 '12 at 16:22
  • Really? Even though there are no further common factors in the remainder? – Simon Hayward Oct 30 '12 at 16:23
  • @SimonHayward: (I did know what the dots meant.) I still don't get it. The problem is why $1+2^p+2^{2p}+...+2^{(m_1-1)p}$ and $1+2^p+2^{2p}+...+2^{(n_1-1)p}$ have no common divisor. I do know why $2^x-1$ divides $2^{yx}-1$, if that might help understanding me. – Bart Michels Oct 30 '12 at 16:26
  • Then you are nearly there!! What if we have $2^{xp}-1$ and $2^{yxp}-1$ can you see that we could factorise to get the answer? Can you see how close this is to what you are asking? Also there are more answers with more detail now.... – Simon Hayward Oct 30 '12 at 16:33
  • You could factorise $2^{xp}-1$. But what does this have to do with my question? – Bart Michels Oct 30 '12 at 16:43
  • 1
    How do you know that there are no other common factors? You've just asserted without proof that the terms in the ellispes ($\dots$) have no common factor. – Thomas Andrews Oct 30 '12 at 17:59
0

This problem can be solved in a very simple manner by throwing everything wisely into induction. Rephrase the statement and do strong induction on $a$. The base case of $a=1$ is trivial to verify. Now let $a\geq1$ be arbitrary and assume that the statement is true for any $k\leq a-1$, that is, for any such $k$, $\gcd(2^k-1,2^b-1)=2^{\gcd(k,b)}-1$ for any $b$. Now, if $b<a$ we are done by the induction hypothesis, so let us focus on the case $b\geq a$. Assume that $b=aq+r, 0\leq r< a$; then, (using the binomial theorem) $$2^b-1=((2^a-1)+1)^q 2^r-1=(\{Integer\; Expression\} (2^a-1)+1)\;2^r-1=\{Integer\; Expression\}\;2^r\; (2^a-1)+(2^r-1).$$ This transforms the problem into calculating $gcd(2^a-1,2^r-1)$, which, by the induction hypothesis is $2^{\gcd(a,r)}-1=2^{\gcd(a,b)}-1$, by the Euclidean Algorithm.