Academy
Maths›Number Theory›Gcd Lcm›GCD — Core Theorems

GCD — Core Theorems

Seven identities that reduce hard GCD problems to one-line arguments — including the power identity, Fibonacci GCD, and Euclid's Lemma. Each with a proof short enough to reconstruct on the spot.

Most GCD problems at JEE Advanced level don't need new ideas. They need you to recognize which of a small set of identities applies, and apply it cleanly.

This page collects those identities. Each one comes with a proof short enough to reconstruct on the spot — because if you understand why it's true, you don't need to memorize it.


Identity 1 — Invariance under linear shifts

gcd⁡(a,b)=gcd⁡(a+kb, b)for any integer k\gcd(a, b) = \gcd(a + kb,\ b) \quad \text{for any integer } k

Proof. Common divisors of (a,b)(a, b) and (a+kb,b)(a + kb, b) are identical: any dd dividing both aa and bb also divides a+kba + kb, and conversely dd dividing a+kba+kb and bb divides (a+kb)−kb=a(a+kb) - kb = a. ■\blacksquare

Special case. gcd⁡(a,b)=gcd⁡(a−b,b)\gcd(a, b) = \gcd(a - b, b). Subtract repeatedly until the Euclidean Algorithm takes over.

JEE use. When you see gcd⁡(f(n),g(n))\gcd(f(n), g(n)) where ff and gg share a polynomial relationship, subtract to simplify.

Example. gcd⁡(n2+1,n+1)\gcd(n^2 + 1, n + 1).

n2+1=(n+1)(n−1)+2n^2 + 1 = (n+1)(n-1) + 2, so gcd⁡(n2+1,n+1)=gcd⁡(2,n+1)\gcd(n^2+1, n+1) = \gcd(2, n+1).

This equals 2 if nn is odd, and 1 if nn is even.


Identity 2 — Scaling

gcd⁡(ma,mb)=m⋅gcd⁡(a,b)for m>0\gcd(ma, mb) = m \cdot \gcd(a, b) \quad \text{for } m > 0

Proof. Write a=dpa = dp, b=dqb = dq, d=gcd⁡(a,b)d = \gcd(a,b), gcd⁡(p,q)=1\gcd(p,q) = 1. Then ma=mdpma = mdp, mb=mdqmb = mdq, and since gcd⁡(p,q)=1\gcd(p,q)=1, we have gcd⁡(ma,mb)=md\gcd(ma,mb) = md. ■\blacksquare

Consequence. Always divide out the GCD first: gcd⁡(a/d,b/d)=1\gcd(a/d, b/d) = 1 where d=gcd⁡(a,b)d = \gcd(a,b). This coprime pair is the "skeleton" — everything about gcd⁡(a,b)\gcd(a,b) lives here.


Identity 3 — The power identity

gcd⁡(an−1, am−1)=agcd⁡(n,m)−1\gcd(a^n - 1,\ a^m - 1) = a^{\gcd(n,m)} - 1

This is the GCD identity that appears most often at JEE Advanced level.

Proof. The key lemma: ak−1∣an−1  ⟺  k∣na^k - 1 \mid a^n - 1 \iff k \mid n.

Why: If n=qkn = qk, then an−1=(ak)q−1=(ak−1)((ak)q−1+⋯+1)a^n - 1 = (a^k)^q - 1 = (a^k - 1)\bigl((a^k)^{q-1} + \cdots + 1\bigr).

Now run the Euclidean algorithm on the exponents. The step gcd⁡(an−1,am−1)\gcd(a^n-1, a^m-1) with n>mn > m:

an−1=an−m(am−1)+(an−m−1)a^n - 1 = a^{n-m}(a^m - 1) + (a^{n-m} - 1)

So gcd⁡(an−1,am−1)=gcd⁡(am−1,an−m−1)\gcd(a^n-1, a^m-1) = \gcd(a^m-1, a^{n-m}-1).

The exponents reduce exactly as in gcd⁡(n,m)\gcd(n, m). The algorithm terminates at agcd⁡(n,m)−1a^{\gcd(n,m)} - 1. ■\blacksquare

Example. gcd⁡(2100−1,275−1)=2gcd⁡(100,75)−1=225−1\gcd(2^{100}-1, 2^{75}-1) = 2^{\gcd(100,75)}-1 = 2^{25}-1.


Identity 4 — Fibonacci GCD

gcd⁡(Fn,Fm)=Fgcd⁡(n,m)\gcd(F_n, F_m) = F_{\gcd(n,m)}

where F1=1,F2=1,F3=2,…F_1 = 1, F_2 = 1, F_3 = 2, \ldots

Proof. The key lemma: Fm∣Fn  ⟺  m∣nF_m \mid F_n \iff m \mid n.

Then use the identity Fm+n=FmFn+1+Fm−1FnF_{m+n} = F_m F_{n+1} + F_{m-1} F_n to show:

gcd⁡(Fm,Fn)=gcd⁡(Fm,Fn mod m)\gcd(F_m, F_n) = \gcd(F_m, F_{n \bmod m})

This is the Euclidean algorithm on Fibonacci indices. It terminates at Fgcd⁡(m,n)F_{\gcd(m,n)}. ■\blacksquare

Example. gcd⁡(F12,F8)=Fgcd⁡(12,8)=F4=3\gcd(F_{12}, F_8) = F_{\gcd(12,8)} = F_4 = 3.


Identity 5 — Consecutive integers are coprime

gcd⁡(n,n+1)=1for all integers n\gcd(n, n+1) = 1 \quad \text{for all integers } n

Proof. Any common divisor dd satisfies d∣(n+1)−n=1d \mid (n+1) - n = 1. ■\blacksquare

More generally: gcd⁡(n,n+k)=gcd⁡(n,k)\gcd(n, n+k) = \gcd(n, k).

The consecutive case is the k=1k=1 instance — and gcd⁡(n,1)=1\gcd(n, 1) = 1 always.


Identity 6 — GCD of an arithmetic progression

If a,a+d,a+2d,…a, a+d, a+2d, \ldots is an arithmetic progression, then:

gcd⁡(all terms)=gcd⁡(a,d)\gcd(\text{all terms}) = \gcd(a, d)

Proof. Every term a+nda + nd satisfies gcd⁡(a+nd,d)=gcd⁡(a,d)\gcd(a + nd, d) = \gcd(a, d) by Identity 1. Taking GCD over all terms gives gcd⁡(a,d)\gcd(a, d). ■\blacksquare


Identity 7 — LCM distributes over GCD

lcm(a,lcm(b,c))=lcm(lcm(a,b),c)(associativity)\text{lcm}(a, \text{lcm}(b, c)) = \text{lcm}(\text{lcm}(a, b), c) \quad \text{(associativity)}

gcd⁡(a,lcm(b,c))=lcm(gcd⁡(a,b),gcd⁡(a,c))(distributivity)\gcd(a, \text{lcm}(b, c)) = \text{lcm}(\gcd(a, b), \gcd(a, c)) \quad \text{(distributivity)}

These hold because both gcd⁡\gcd and lcm\text{lcm} operate prime-by-prime: gcd⁡\gcd takes the minimum exponent at each prime, lcm\text{lcm} takes the maximum. Min and max distribute over each other.


Worked problems

Problem 1. Find gcd⁡(2100−1,275−1)\gcd(2^{100}-1, 2^{75}-1).

Identity 3 directly: gcd⁡(100,75)=25\gcd(100, 75) = 25. Answer: 225−12^{25}-1.

Problem 2. Find all nn such that n+1∣n2+1n + 1 \mid n^2 + 1.

Identity 1: n2+1=(n+1)(n−1)+2n^2+1 = (n+1)(n-1) + 2, so gcd⁡(n2+1,n+1)=gcd⁡(2,n+1)\gcd(n^2+1, n+1) = \gcd(2, n+1).

For n+1∣n2+1n+1 \mid n^2+1, we need n+1∣2n+1 \mid 2. So n+1∈{−2,−1,1,2}n+1 \in \{-2,-1,1,2\}, giving n∈{−3,−2,0,1}n \in \{-3,-2,0,1\}.

Problem 3. Prove gcd⁡(a,b)⋅gcd⁡(a,c)=gcd⁡(a,bc)⋅gcd⁡(a,gcd⁡(b,c))\gcd(a,b) \cdot \gcd(a,c) = \gcd(a, bc) \cdot \gcd(a, \gcd(b,c)) when gcd⁡(b,c)=1\gcd(b,c)=1.

When gcd⁡(b,c)=1\gcd(b,c)=1, the right side becomes gcd⁡(a,bc)⋅1\gcd(a, bc) \cdot 1. So the claim reduces to gcd⁡(a,b)⋅gcd⁡(a,c)=gcd⁡(a,bc)\gcd(a,b)\cdot\gcd(a,c) = \gcd(a,bc) — which follows from the prime-by-prime min/max structure.

Problem 4. Find gcd⁡(n!+1,(n+1)!+1)\gcd(n!+1, (n+1)!+1).

(n+1)!+1=(n+1)⋅n!+1(n+1)! + 1 = (n+1) \cdot n! + 1.

gcd⁡(n!+1,(n+1)!+1)=gcd⁡(n!+1, (n+1)n!+1−(n+1)(n!+1))=gcd⁡(n!+1,−n)=gcd⁡(n!+1,n)\gcd(n!+1, (n+1)!+1) = \gcd(n!+1,\ (n+1)n!+1-(n+1)(n!+1)) = \gcd(n!+1, -n)= \gcd(n!+1, n).

Since n∣n!n \mid n!, we have n!≡0(modn)n! \equiv 0 \pmod n, so n!+1≡1(modn)n!+1 \equiv 1 \pmod n. Thus gcd⁡(n!+1,n)=1\gcd(n!+1, n) = 1.

Answer: gcd⁡(n!+1,(n+1)!+1)=1\gcd(n!+1, (n+1)!+1) = 1 for all n≥1n \geq 1.

Problem 5. Prove: if gcd⁡(a,b)=1\gcd(a,b)=1, then gcd⁡(a+b,a2−ab+b2)∈{1,3}\gcd(a+b, a^2 - ab + b^2) \in \{1, 3\}.

Let d=gcd⁡(a+b,a2−ab+b2)d = \gcd(a+b, a^2-ab+b^2).

Note a2−ab+b2=(a+b)2−3aba^2-ab+b^2 = (a+b)^2 - 3ab.

So d∣(a+b)2−(a2−ab+b2)=3abd \mid (a+b)^2 - (a^2-ab+b^2) = 3ab.

If prime p∣dp \mid d and p∣ap \mid a: then p∣a+bp \mid a+b forces p∣bp \mid b, contradicting gcd⁡(a,b)=1\gcd(a,b)=1.

So gcd⁡(d,a)=gcd⁡(d,b)=1\gcd(d, a) = \gcd(d, b) = 1, hence d∣3d \mid 3.

Therefore d∈{1,3}d \in \{1, 3\}. ■\blacksquare


The pattern to internalize

Every identity here follows one of two moves:

  1. Replace by remainder — gcd⁡(a,b)=gcd⁡(b,a mod b)\gcd(a,b) = \gcd(b, a \bmod b), the Euclidean step.
  2. Use linear combinations — d∣ad \mid a and d∣bd \mid b implies d∣ax+byd \mid ax + by.

When a GCD problem looks hard, ask: which of these two moves simplifies it?