elementary number theory
GCD and LCM
You should know: divisibility
Overview
The greatest common divisor (GCD), also called the greatest common factor (GCF), of two or more integers not all zero is the largest positive integer that divides each of them. For two integers x and y, the greatest common divisor is denoted gcd(x, y); for example, gcd(8, 12) = 4. The least common multiple (LCM) is the smallest positive integer that is a multiple of each of the given integers, e.g. lcm(4, 6) = 12. GCD and LCM are dual notions connected by the identity gcd(a,b)·lcm(a,b) = a·b, and both are computed efficiently via the Euclidean algorithm.
Formal Definition
For nonzero integers a and b:
Worked Examples
Divisors of 8: {1,2,4,8}. Divisors of 12: {1,2,3,4,6,12}. Largest common divisor is 4.
Use the product identity to get the LCM without listing multiples.
Answer: gcd(8,12) = 4, lcm(8,12) = 24.
Practice Problems
Find gcd(18, 24) and lcm(18, 24).
Two maintenance tasks are done every 12 and every 18 days respectively, and both happen today. In how many days will they next coincide?
A floor 240 cm by 180 cm is to be covered exactly by identical square tiles as large as possible with no cutting. What is the tile side length?
Quiz
Summary
- gcd(a,b) is the largest integer dividing both a and b; lcm(a,b) is the smallest positive multiple of both.
- Product identity: gcd(a,b) · lcm(a,b) = |a·b|, letting you compute one from the other.
- The Euclidean algorithm computes gcd(a,b) efficiently via repeated division: gcd(a,b) = gcd(b, a mod b).
Mathematics