Skip to content

Commit 63cec14

Browse files
Oleksandr Kulkovadamant-pwn
Oleksandr Kulkov
authored andcommitted
clarification
1 parent 618713c commit 63cec14

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/algebra/euclid-algorithm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ e_maxx_link: euclid_algorithm
99
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$.
1010
It's commonly denoted by $\gcd(a, b)$. Mathematically it is defined as:
1111

12-
$$\gcd(a, b) = \max \{k : k \mid a \wedge k \mid b \}$$
12+
$$\gcd(a, b) = \max \{k > 0 : (k \mid a) \wedge (k \mid b) \}$$
1313

1414
(here the symbol "$\mid$" denotes divisibility, i.e. "$k \mid a$" means "$k$ divides $a$")
1515

16-
When one of the numbers is zero, while the other is non-zero, their greatest common divisor, by definition, is the second number. When both numbers are zero, their greatest common divisor is undefined (it can be any arbitrarily large number), but we can define it to be zero. Which gives us a simple rule: if one of the numbers is zero, the greatest common divisor is the other number.
16+
When one of the numbers is zero, while the other is non-zero, their greatest common divisor, by definition, is the second number. When both numbers are zero, their greatest common divisor is undefined (it can be any arbitrarily large number), but it is convenient to define it as zero as well to preserve the associativity of $\gcd$. Which gives us a simple rule: if one of the numbers is zero, the greatest common divisor is the other number.
1717

1818
The Euclidean algorithm, discussed below, allows to find the greatest common divisor of two numbers $a$ and $b$ in $O(\log \min(a, b))$.
1919

0 commit comments

Comments
 (0)