ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Discrete Structures
    GE-167
    Progress0 / 67 topics
    Topics
    1. Mathematical Reasoning: Propositional and Predicate Logic2. Propositional Logic: Logical Operators3. Translations Between Symbolic Expressions and Formal English Expression4. Logical Equivalences5. Predicate Logic: Quantifiers6. Nested Quantification7. Equivalences in Predicate Logic8. Translations Between Symbolic Forms and Formal English9. Rules of Inference: Proof Methods and Strategies10. Direct Proof11. Proof by Contraposition12. Proof by Induction13. Proof by Implication14. Existence Proof15. Uniqueness Proofs16. Trivial Proofs17. Vacuous Proofs18. Sets: Notations and Set Operations19. Venn Diagrams20. Countable and Uncountable Sets21. Relations: Equivalence Relations and Partitions22. Partial Orderings23. Recurrence Relations24. Functions: Injective, Surjective, Bijective25. Special Types of Functions26. Function Composition27. Inverse Functions28. Recursive Functions29. Compositions30. Number Theory: Sequences and Series31. Counting: Inclusion and Exclusion Principle32. Pigeonhole Principle33. Permutations and Combinations34. Integers and Divisibility: Division Theorem35. Modular Arithmetic36. LCM and GCD37. Euclidean and Extended Euclidean Method38. Finding Solutions to Congruence39. Primes: Fundamental Theorem of Arithmetic40. Characterizations of Primes41. Mersenne Primes42. Induction: Weak Induction43. Strong Induction44. Recursion and Recurrences: Formulation of Recurrences45. Closed Formulas46. Counting: Product Rule and Sum Rule47. Principle of Inclusion-Exclusion48. Binomial Coefficients49. Pascal's Identity and Pascal’s Triangle50. Binomial Theorem51. Relations: Reflexive, Symmetric, Transitive, and Antisymmetric52. Equivalence Relations and Equivalence Classes53. Partial Orders54. Graph Theory: Terminologies55. Elements of Graph Theory56. Planar Graphs57. Graph Coloring58. Euler Graph59. Hamiltonian Path60. Rooted Trees61. Graph Traversals62. Handshaking Lemma and Corollary63. Special Families of Graphs64. Graph Isomorphism65. Planarity in Graphs66. Eulerian and Hamiltonian Graphs67. Trees in Graph Theory
    GE-167›Euclidean and Extended Euclidean Method
    Discrete StructuresTopic 37 of 67

    Euclidean and Extended Euclidean Method

    10 minread
    1,736words
    Intermediatelevel

    Euclidean Algorithm and Extended Euclidean Algorithm

    The Euclidean Algorithm and Extended Euclidean Algorithm are two fundamental methods in number theory used to compute the Greatest Common Divisor (GCD) of two integers. The Euclidean Algorithm is a classic, efficient method for finding the GCD, while the Extended Euclidean Algorithm also computes additional information, such as the coefficients of the linear combination of the integers involved.


    1. Euclidean Algorithm

    The Euclidean Algorithm is an efficient method for finding the GCD of two integers aaa and bbb. It works by repeatedly applying the division algorithm (dividing the larger number by the smaller one and replacing the larger number with the remainder) until the remainder is zero. The last non-zero remainder is the GCD of the two numbers.

    Steps to Apply the Euclidean Algorithm:

    1. Given two numbers aaa and bbb, where a>ba > ba>b, divide aaa by bbb and obtain the quotient and remainder:

      a=b×q+ra = b \times q + ra=b×q+r

      where qqq is the quotient and rrr is the remainder.

    2. Replace aaa with bbb and bbb with rrr, and repeat the process until r=0r = 0r=0.

    3. When the remainder becomes zero, the GCD is the last non-zero remainder.

    Example: Finding gcd⁡(48,18)\gcd(48, 18)gcd(48,18)

    Let’s use the Euclidean algorithm to find gcd⁡(48,18)\gcd(48, 18)gcd(48,18):

    1. Divide 48 by 18:

      48÷18=2(quotient),48−18×2=48−36=12(remainder)48 \div 18 = 2 \quad \text{(quotient)}, \quad 48 - 18 \times 2 = 48 - 36 = 12 \quad \text{(remainder)}48÷18=2(quotient),48−18×2=48−36=12(remainder)

      So, gcd⁡(48,18)=gcd⁡(18,12)\gcd(48, 18) = \gcd(18, 12)gcd(48,18)=gcd(18,12).

    2. Divide 18 by 12:

      18÷12=1(quotient),18−12×1=18−12=6(remainder)18 \div 12 = 1 \quad \text{(quotient)}, \quad 18 - 12 \times 1 = 18 - 12 = 6 \quad \text{(remainder)}18÷12=1(quotient),18−12×1=18−12=6(remainder)

      So, gcd⁡(18,12)=gcd⁡(12,6)\gcd(18, 12) = \gcd(12, 6)gcd(18,12)=gcd(12,6).

    3. Divide 12 by 6:

      12÷6=2(quotient),12−6×2=12−12=0(remainder)12 \div 6 = 2 \quad \text{(quotient)}, \quad 12 - 6 \times 2 = 12 - 12 = 0 \quad \text{(remainder)}12÷6=2(quotient),12−6×2=12−12=0(remainder)

      The remainder is now 0, so the GCD is 6.

    Thus, gcd⁡(48,18)=6\gcd(48, 18) = 6gcd(48,18)=6.


    2. Extended Euclidean Algorithm

    The Extended Euclidean Algorithm not only computes the GCD of two integers aaa and bbb, but also finds the coefficients xxx and yyy (called Bezout coefficients) such that:

    a×x+b×y=gcd⁡(a,b)a \times x + b \times y = \gcd(a, b)a×x+b×y=gcd(a,b)

    In other words, the Extended Euclidean Algorithm expresses the GCD of aaa and bbb as a linear combination of aaa and bbb.

    This is particularly useful in many areas, such as modular arithmetic, where we need to find the modular inverse of a number.

    Steps to Apply the Extended Euclidean Algorithm:

    1. Use the Euclidean algorithm to find the GCD of aaa and bbb.
    2. While performing the steps of the Euclidean algorithm, also keep track of the coefficients of aaa and bbb in the linear combinations.
    3. After completing the Euclidean algorithm, backtrack through the steps to express the GCD as a linear combination of aaa and bbb.

    Example: Extended Euclidean Algorithm for gcd⁡(48,18)\gcd(48, 18)gcd(48,18)

    We will use the Extended Euclidean Algorithm to find the GCD and the Bezout coefficients for gcd⁡(48,18)\gcd(48, 18)gcd(48,18).

    1. Start by applying the Euclidean algorithm:

      48÷18=2(quotient),48−18×2=12(remainder)48 \div 18 = 2 \quad \text{(quotient)}, \quad 48 - 18 \times 2 = 12 \quad \text{(remainder)}48÷18=2(quotient),48−18×2=12(remainder)

      So, gcd⁡(48,18)=gcd⁡(18,12)\gcd(48, 18) = \gcd(18, 12)gcd(48,18)=gcd(18,12).

      18÷12=1(quotient),18−12×1=6(remainder)18 \div 12 = 1 \quad \text{(quotient)}, \quad 18 - 12 \times 1 = 6 \quad \text{(remainder)}18÷12=1(quotient),18−12×1=6(remainder)

      So, gcd⁡(18,12)=gcd⁡(12,6)\gcd(18, 12) = \gcd(12, 6)gcd(18,12)=gcd(12,6).

      12÷6=2(quotient),12−6×2=0(remainder)12 \div 6 = 2 \quad \text{(quotient)}, \quad 12 - 6 \times 2 = 0 \quad \text{(remainder)}12÷6=2(quotient),12−6×2=0(remainder)

      The remainder is now 0, so the GCD is 6.

    2. Now, backtrack to express 6 as a linear combination of 48 and 18:

      • From 18−12×1=618 - 12 \times 1 = 618−12×1=6, we have: 6=18−12×16 = 18 - 12 \times 16=18−12×1
      • From 48−18×2=1248 - 18 \times 2 = 1248−18×2=12, we substitute 121212 from the previous step: 12=48−18×212 = 48 - 18 \times 212=48−18×2 Substituting this into the equation for 6: 6=18−(48−18×2)×16 = 18 - (48 - 18 \times 2) \times 16=18−(48−18×2)×1 Simplifying: 6=18−48+18×26 = 18 - 48 + 18 \times 26=18−48+18×2 6=3×18−486 = 3 \times 18 - 486=3×18−48

    Thus, we have expressed 6 as a linear combination of 48 and 18:

    6=3×18−1×486 = 3 \times 18 - 1 \times 486=3×18−1×48

    So, the Bezout coefficients are x=−1x = -1x=−1 and y=3y = 3y=3.

    This means that:

    48×(−1)+18×3=648 \times (-1) + 18 \times 3 = 648×(−1)+18×3=6

    General Formula:

    If you run the Extended Euclidean Algorithm on integers aaa and bbb, you will get gcd⁡(a,b)=ax+by\gcd(a, b) = ax + bygcd(a,b)=ax+by, where xxx and yyy are the coefficients of aaa and bbb in the linear combination.


    3. Applications of the Extended Euclidean Algorithm

    • Modular Inverse: One of the most common applications of the Extended Euclidean Algorithm is finding the modular inverse of a number. If aaa and mmm are coprime (i.e., gcd⁡(a,m)=1\gcd(a, m) = 1gcd(a,m)=1), then the modular inverse of aaa modulo mmm is the xxx-coefficient in the equation ax+my=1ax + my = 1ax+my=1. The modular inverse is useful in cryptographic algorithms like RSA.

    • Diophantine Equations: The Extended Euclidean Algorithm is used to find integer solutions to linear Diophantine equations of the form ax+by=cax + by = cax+by=c.

    • Cryptography: In RSA and other cryptographic systems, the Extended Euclidean Algorithm is used to compute the private key from the public key.

    • Solving Linear Systems: The algorithm can be used to solve systems of linear equations where the coefficients are integers.


    4. Conclusion

    • The Euclidean Algorithm is a fast method for computing the GCD of two integers by repeated division and finding remainders.
    • The Extended Euclidean Algorithm not only computes the GCD but also finds the coefficients (Bezout coefficients) that express the GCD as a linear combination of the two integers. This is crucial for solving problems like finding modular inverses and solving Diophantine equations.
    Previous topic 36
    LCM and GCD
    Next topic 38
    Finding Solutions to Congruence

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time10 min
      Word count1,736
      Code examples0
      DifficultyIntermediate