gcd(2^m − 1, 2^n − 1): the proof, and how to spot it
12 October 2026
Nobody gets stuck on this problem because the algebra is hard. Every line of the proof is a factorisation you already know. People get stuck because they try to attack and as numbers, factoring them, hunting for primes, and the numbers are the wrong thing to look at.
The whole proof is one observation: the Euclidean algorithm on the exponents produces the Euclidean algorithm on the numbers, step for step. Once you see that, the identity
stops being a fact to memorise and becomes something you can rebuild in two minutes in an exam. This guide shows the proof, a second proof by orders, and the problems where it quietly does the work.
Believe it first
Take and . Then and . Run Euclid on those: leaves remainder on division by , and , so the gcd is .
Now look at the exponents. , and . Same answer.
Look closer at that first remainder. Euclid on the exponents says , remainder . Euclid on the numbers gave remainder . The remainder on the numbers is to the remainder on the exponents, minus one. That is not a coincidence, and it is the entire proof.
The one fact you need
If divides , then divides . Write and ; then , and always divides , because
You have probably met this already. It is the same factorisation that shows if is prime then is prime: a composite exponent hands you a proper factor for free.
The proof
Take and divide: with . Split off the remainder in the exponent:
Expand the right side if you doubt it: . Now divides , so by the fact above divides . That kills the first term modulo , leaving
And a gcd does not change when you replace one number by its remainder modulo the other. So
The pair of exponents went from to , which is exactly one step of Euclid on and . Repeat. The exponents follow Euclid's algorithm all the way down until the remainder is , at which point the exponent pair is , and the numbers are and . The gcd of anything with is itself. Done.
On the example: on the exponents, and on the numbers. Every exponent on the left becomes on the right.
This is the problem in the archive, and when you write it up, the marker is looking for two things: the congruence with a reason attached, and an honest ending at remainder rather than "and so on".
A second proof, by orders
The first proof is the one to write. This one is worth knowing because it generalises to problems where Euclid has nothing to run on, and it is pure modular thinking.
Let . Then modulo we have both and . Any power of built by adding and subtracting multiples of and is therefore also . By Bézout, can be written as with (for and : ). So , and since both and are , we get . That is, divides .
The other direction is the one fact from earlier: divides both and , so divides both numbers, hence divides . Each divides the other, so they are equal.
How to spot it next time
The identity hides behind several disguises. Reach for it when you see:
- Two numbers one less than a power, same base, like and . Nothing about is special. The same proof gives for any integer .
- Repunits. with ones is , so the gcd of the repunits with and ones is the repunit with ones. The repunits with and ones share exactly .
- "Show these are coprime." Since , the numbers and are coprime exactly when and are. Take over all primes : they are pairwise coprime, so each one contributes a prime the others lack, and that is a proof there are infinitely many primes.
- An exponent that is clearly a gcd or lcm in disguise. If the answer to a question is and the inputs mention and , you now know where the came from.
What to write in the exam
Four lines are enough:
- Divide with remainder: .
- State the congruence , with the factorisation as its reason.
- Conclude the gcd is unchanged when becomes .
- Say the process is Euclid's algorithm on the exponents and finishes at .
If you can produce those four lines from memory, you do not need to remember the formula. You need to remember that exponents run Euclid too.
Related guides
- How to build a problem-solving notebook that actually worksMost problem notebooks are copied solutions nobody reopens. Index yours by the clue in the statement, not by topic, and test it from the clue side.
- What separates a Level 5 problem from a Level 7, side by sideTwo IMO inequalities, both rated 5 out of 6, sit two rungs apart on the ladder. What actually separates a Level 5 problem from a Level 7, and how to cross.
- Number theory problems that look like algebra, and how to tellAn equation, a fraction, a polynomial: it reads like algebra, but the word integer changes the method. Five signals, and the three moves that follow.
- How to revise a topic you understand but keep missingRereading a topic you already understand fixes nothing. Find the one step that keeps breaking, revise that step, and test it cold. Worked on mods and bounds.
Train it on Lemma
Every technique here is taught explicitly, in order. 125 lessons, 1206 curated problems and unlimited generated practice at six difficulties. Free to start, no card, and every paid plan opens with 3 free days.
Find your level