GCD and LCM with a Venn Diagram

Category: Number Theory   Level: 101

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

Put the prime factors of two numbers in a Venn diagram. The overlap multiplies to the GCD, and everything together multiplies to the LCM.

Step through it

Watch it

Animated walkthrough

Step by step

Step 1: Factor both numbers

Break each number into primes. Both lists contain a 2 and a 3, which is where the two numbers overlap.

12 = 2 × 2 × 3, 18 = 2 × 3 × 3

Step 1: Factor both numbers

Step 2: Put shared primes in the overlap

Draw a circle for each number. One 2 and one 3 belong to both, so they sit where the circles overlap.

shared: 2 × 3

Step 2: Put shared primes in the overlap

Step 3: Put the leftovers outside the overlap

12 has one more 2, and 18 has one more 3. Each goes in its own circle only.

12 = 2 × 3 × 2, 18 = 2 × 3 × 3

Step 3: Put the leftovers outside the overlap

Step 4: The overlap is the GCD

Multiply the primes in the overlap. That is the biggest number that divides both, so it is the greatest common divisor.

gcd(12, 18) = 2 × 3 = 6

Step 4: The overlap is the GCD

Step 5: Everything together is the LCM

Multiply every prime in the picture, each one once. The result is the smallest number both divide into, the least common multiple.

lcm(12, 18) = 2 × 2 × 3 × 3 = 36

Step 5: Everything together is the LCM

Step 6: Check the shortcut

The GCD holds the shared primes, and the LCM holds every prime once. Together they hold the shared primes twice and the rest once, just like 12 × 18. A free check.

6 × 36 = 216 = 12 × 18

Step 6: Check the shortcut

All steps at once

Storyboard

Generate it yourself

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

Source: svgmath/diagrams/gcd_lcm.py