Skip to content

Greatest common divisor

Greatest common divisor

The GCD of two numbers is the largest integer that divides both. Euclid's algorithm is beautifully short: while b isn't 0, replace the pair (a, b) with (b, a % b). When b reaches 0, a is the answer.

Log in or create account

IGCSE & A-Level