Euclidean algorithm for computing the greatest common divisor - Algorithms for Competitive Programming
Given two non-negative integers β β π <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>a</mi></math> $a$β and β β π <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>b</mi></math> $b$β, we have to find their GCD (greatest common divisor), i.e. the largest number which is a divisor of both β β π <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>a</mi></math> $a$β and β β π <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>b</mi></math> $b$β. It's commonly denoted by β β gcd ( π , π ) <math xmlns="http://www.w3.org/1998/Math/MathML"><mo data-mjx-texclass="OP" movablelimits="true">gcd</mo><mo stretchy="false">(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo stretchy="false">)</mo></math> $\gcd(a, b)$β. Mathematically it is defined as: (here the symbol "β β β£ <math xmlns="http://www.w3.org/1998/Math/MathML"><mo>β£</mo></math> $\mid$β" denotes divisibility, i.e. "β β π β£ π <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>k</mi><mo>β£</mo><mi>a</mi></math> $k \mid a$β" means "
Last update: October 15, 2024   Translated From: e-maxx.ru Euclidean algorithm for computing the greatest common divisor ¶ Given two non-negative integers $a$ and $b$ , we have to find their GCD (greatest common divisor), i.e. the largest number which is a divisor of both $a$ and $b$ . It's commonly denoted by $\gcd(a, b)$ . Mathematically it is defined as: $$\gcd(a, b) = \max \{k > 0 : (k \mid a) \text{ and } (k \mid b) \}$$ (here the symbol " $\mid$ " denotes divisibility, i.e. " $k \mid a$ " means " $k$ divides $a$ ") When one of the numbers is zero, while the other is non-zero, t
Explore this link on the map βsaved by
related reading
- Extended Euclidean Algorithm - Algorithms for Competitive Programmingcp-algorithms.com
- Fibonacci Numbers - Algorithms for Competitive Programmingcp-algorithms.com
- Binary Exponentiation - Algorithms for Competitive Programmingcp-algorithms.com
- Introduction to Dynamic Programming - Algorithms for Competitive Programmingcp-algorithms.com
- Competitive Programmer's Handbookcses.fi
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu
- Structure and Interpretation of Computer Programs, 2e: 1.2sarabander.github.io
- Algorithms for Modern Hardware - Algorithmicaen.algorithmica.org
- Math & Engineeringxn--2-umb.com
- The Aggregate Magic Algorithmsaggregate.org
- Labor of Division (Episode IV): Algorithm Dridiculousfish.com
- What's new | Updates on my research and expository papers, discussion of open problems, and other maths-related topics. By Terence Taoterrytao.wordpress.com