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.
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
Draw a circle for each number. One 2 and one 3 belong to both, so they sit where the circles overlap.
shared: 2 × 3
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
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
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
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
cd svg-generator python3 -m svgmath render gcd-lcm-venn --out /tmp/gcd-lcm-venn
Source: svgmath/diagrams/gcd_lcm.py