GCD LCM and Algorithms

Loading concept...

The Secret Language of Numbers: GCD, LCM & Magical Algorithms 🎭

Imagine you have two boxes of chocolates. One has 12, another has 18. How can you share them equally among friends without breaking any chocolate? This is exactly what GCD and LCM help us solve!


🌟 Our Journey Today

Think of numbers like family members. Some numbers share common relatives (divisors), and understanding these relationships unlocks powerful problem-solving magic!


1. Greatest Common Divisor (GCD) — The Biggest Shared Gift

What is GCD?

The Greatest Common Divisor is the biggest number that can divide two numbers perfectly (no leftovers!).

Simple Example: Sharing Chocolates

You have 12 chocolates and your friend has 18 chocolates. You both want to make identical gift bags with the same number in each.

Divisors of 12: 1, 2, 3, 4, 6, 12 Divisors of 18: 1, 2, 3, 6, 9, 18

Common divisors: 1, 2, 3, 6 Greatest common divisor: 6

You can make bags of 6 chocolates each!

Another Example

GCD(24, 36) = ?

24’s divisors 36’s divisors
1, 2, 3, 4, 6, 8, 12, 24 1, 2, 3, 4, 6, 9, 12, 18, 36

Common: 1, 2, 3, 4, 6, 12 GCD = 12


2. Least Common Multiple (LCM) — The First Meeting Point

What is LCM?

The Least Common Multiple is the smallest number that both numbers can divide into perfectly.

Simple Example: Bus Schedules

🚌 Bus A comes every 4 minutes 🚌 Bus B comes every 6 minutes

When will both buses arrive together?

Multiples of 4: 4, 8, 12, 16, 20, 24Multiples of 6: 6, 12, 18, 24

First common multiple: 12 minutes!

Another Example

LCM(5, 7) = ?

  • Multiples of 5: 5, 10, 15, 20, 25, 30, 35
  • Multiples of 7: 7, 14, 21, 28, 35

LCM = 35


3. The GCD-LCM Relationship — A Beautiful Formula!

The Magic Connection

Here’s something wonderful:

GCD(a, b) × LCM(a, b) = a × b

Why Does This Work?

Think of it like a seesaw!

  • GCD finds what numbers share
  • LCM finds where numbers meet
  • Together, they balance perfectly!

Example Proof

Let’s verify with 12 and 18:

What we know Value
GCD(12, 18) 6
LCM(12, 18) 36
GCD × LCM 6 × 36 = 216
12 × 18 216

Quick Formula for LCM

Since we know: GCD × LCM = a × b

We can find: LCM = (a × b) ÷ GCD

Example: LCM(12, 18) = (12 × 18) ÷ 6 = 216 ÷ 6 = 36


4. Coprime Numbers — Numbers with No Common Ground

What are Coprime Numbers?

Two numbers are coprime (or relatively prime) when their only common divisor is 1.

They’re like strangers who share nothing except the number 1!

Examples

Pair GCD Coprime?
8 and 15 1 ✅ Yes!
9 and 12 3 ❌ No
14 and 25 1 ✅ Yes!
7 and 11 1 ✅ Yes!

Fun Fact

Any two consecutive numbers (like 7 and 8) are always coprime!

Why? Because if something divides both n and n+1, it must divide their difference (which is 1). Only 1 divides 1!


5. Euclidean Algorithm — The Ancient Speed Trick

The Story

Over 2,300 years ago, a Greek mathematician named Euclid discovered a super-fast way to find GCD!

The Big Idea

Instead of listing all divisors, we use this clever observation:

GCD(a, b) = GCD(b, a mod b)

Keep replacing until the remainder is 0!

Step-by-Step Example

Find GCD(48, 18):

Step 1: 48 ÷ 18 = 2 remainder 12
        GCD(48, 18) = GCD(18, 12)

Step 2: 18 ÷ 12 = 1 remainder 6
        GCD(18, 12) = GCD(12, 6)

Step 3: 12 ÷ 6 = 2 remainder 0
        GCD(12, 6) = GCD(6, 0)

Answer: GCD = 6 ✅

Visual Flow

graph TD A["GCD#40;48, 18#41;"] --> B["48 mod 18 = 12"] B --> C["GCD#40;18, 12#41;"] C --> D["18 mod 12 = 6"] D --> E["GCD#40;12, 6#41;"] E --> F["12 mod 6 = 0"] F --> G["GCD = 6 🎉"]

Another Example

GCD(252, 105):

Step Calculation Result
1 252 mod 105 42
2 105 mod 42 21
3 42 mod 21 0

GCD = 21


6. Extended Euclidean Algorithm — Finding Hidden Treasure

What’s the Extension?

The Extended Euclidean Algorithm doesn’t just find GCD—it also finds two special numbers x and y such that:

a × x + b × y = GCD(a, b)

Why Is This Useful?

This is super powerful for:

  • Solving puzzles
  • Cryptography (secret codes!)
  • Finding modular inverses

Example: GCD(30, 12) = 6

We want to find x and y where: 30x + 12y = 6

Working backwards from Euclidean Algorithm:

Step 1: 30 = 2 × 12 + 6
        So: 6 = 30 - 2 × 12

This means: x = 1, y = -2

Check: 30(1) + 12(-2) = 30 - 24 = 6 ✅

The Process

graph TD A["Start: Find x, y for ax + by = GCD"] A --> B["Run Euclidean Algorithm Forward"] B --> C["Track each step's equation"] C --> D["Substitute backwards"] D --> E["Get x and y values!"]

7. Bézout’s Identity — The Mathematical Promise

The Theorem

For any two integers a and b, there exist integers x and y such that:

a × x + b × y = GCD(a, b)

This is called Bézout’s Identity (named after French mathematician Étienne Bézout).

What Makes It Special?

The GCD is the smallest positive number that can be written as a combination of a and b!

Example

For a = 15 and b = 6:

  • GCD(15, 6) = 3
  • Can we write 3 = 15x + 6y?

Yes! 15(1) + 6(-2) = 15 - 12 = 3

Key Insight

If GCD(a, b) = 1 (coprime), then we can write: 1 = ax + by for some integers x, y

This is incredibly useful in modular arithmetic!

Visual Summary

graph TD A["Two Numbers: a, b"] --> B["Find GCD"] B --> C["Bézout's Identity"] C --> D["ax + by = GCD"] D --> E["Extended Euclidean finds x, y"]

🎯 Quick Reference

Concept What It Does Key Formula
GCD Biggest shared divisor GCD(48,18) = 6
LCM Smallest shared multiple LCM(4,6) = 12
Relationship Links GCD and LCM GCD × LCM = a × b
Coprime GCD equals 1 GCD(8,15) = 1
Euclidean Fast GCD finder GCD(a,b) = GCD(b, a mod b)
Extended Finds x, y in ax+by=GCD Works backwards
Bézout Guarantees solution exists ax + by = GCD always works

🌈 Remember This!

  1. GCD = The biggest gift everyone can share equally
  2. LCM = The first moment two buses meet again
  3. Coprime = Numbers that are strangers (share only 1)
  4. Euclidean Algorithm = Ancient Greek speed magic
  5. Extended + Bézout = Finding the treasure map!

Now you know the secret language of numbers! These tools help mathematicians, computer scientists, and cryptographers solve amazing problems every day. 🚀

Loading story...

No Story Available

This concept doesn't have a story yet.

Story Preview

Story - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

Interactive Preview

Interactive - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Interactive Content

This concept doesn't have interactive content yet.

Cheatsheet Preview

Cheatsheet - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Cheatsheet Available

This concept doesn't have a cheatsheet yet.

Quiz Preview

Quiz - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Quiz Available

This concept doesn't have a quiz yet.