‹ Class 9 · Ch 11
The World of Algorithms · Principle 21 of 29

When to stop

Stopping condition gcd(m, 0)

Stuck? Ask Guru

NCERT: 11.3.3 Euclid's Subtraction Algorithm — Reducing a problem to a simpler one

Think

Where does it end?

Each reduction gives a smaller problem: gcd(m, n) becomes gcd(n, m − n). We cannot keep reducing for ever.
The book asks: what is gcd(23, 23)? Clearly 23.

Reducing gcd(23, 23) gives gcd(23, 23 − 23) = gcd(23, 0). So gcd(23, 0) must be …

What this lesson covers

The idea

When the reduction reaches gcd(m, 0), the answer is m.

Where does it end?

Each reduction gives a smaller problem: gcd(m, n) becomes gcd(n, m − n). We cannot keep reducing for ever. The book asks: what is gcd(23, 23)? Clearly 23.

Reducing gcd(23, 23) gives gcd(23, 23 − 23) = gcd(23, 0). So gcd(23, 0) must be …

  • 23
  • 0
  • It has no answer

Reduce gcd(23, 23)

Run Euclid's steps on gcd(23, 23). Watch what the pair becomes.

Stop at n = 0

When the reduction reaches gcd(m, 0), the answer is m.

gcd(23, 23) reduces to gcd(23, 0), and gcd(23, 23) = 23, so gcd(23, 0) = 23. This makes sense: every number divides 0 (0 = 0 × d), so the common divisors of m and 0 are just the divisors of m, and the greatest is m. In the book's run for 375 and 825, the last pair is gcd(75, 0), so the answer is 75.

Notes

Stopping condition: if we reach gcd(m, 0), the answer is m.

Check yourself

What is gcd(75, 0)?

Answer: 75

gcd(m, 0) = m, so gcd(75, 0) = 75.

Why is gcd(m, 0) = m?

  • Every number divides 0, so the common divisors are the divisors of m; the greatest is m — correct. Yes.
  • Because 0 is the smallest number. That is not the reason.
  • Because m − 0 = m. That is true but does not explain the gcd.