GCD and LCM by Listing

Category: Number Theory   Level: 101

gcd(12, 18) = 6, lcm(12, 18) = 36

List the factors of both numbers and take the biggest one they share. Hop along the multiples of both numbers and take the first place they meet.

Step through it

Watch it

Animated walkthrough

Step by step

Step 1: List the factors of each number

12 has 6 factors and 18 has 6. Write them in order, small to big.

12: 1, 2, 3, 4, 6, 12; 18: 1, 2, 3, 6, 9, 18

Step 1: List the factors of each number

Step 2: Find the shared factors, take the biggest

Both lists contain 1, 2, 3, and 6. The biggest shared factor is 6, the GCD.

common: 1, 2, 3, 6 ⇒ gcd = 6

Step 2: Find the shared factors, take the biggest

Step 3: Hop by 12 and by 18

Now look at multiples. One frog hops 12 at a time, another hops 18 at a time, both starting at 0.

12, 24, 36, 48, 60, 72; 18, 36, 54, 72

Step 3: Hop by 12 and by 18

Step 4: The first meeting point is the LCM

Both frogs land on 36 first. That is the smallest common multiple. They meet again at 72, and every 36 after that.

lcm(12, 18) = 36

Step 4: The first meeting point is the LCM

All steps at once

Storyboard

Generate it yourself

cd svg-generator
python3 -m svgmath render gcd-lcm-lists --out /tmp/gcd-lcm-lists

Source: svgmath/diagrams/gcd_lcm.py