This commit is contained in:
John Gatward committed 2026-10-04 15:24:17 +01:00
1 parent d0f27f276b
commit d6f54d4ec2
103 files changed
+3663 -3779

No files matched your search

@@ -11,15 +11,15 @@ $$
#### Euclidean Algorithm
- The euclidean algorithm calculates the greatest common divisor of two numbers $gcd(r_0, r_1)$
- This is the largest number that divides both $r_0$ and $r_1$
- The Euclidean algorithm calculates the greatest common divisor of two numbers $gcd(r_0, r_1)$
- This is the largest number that divides both $r_0$ and $r_1$
- If $gcd(x,y)=1$ then $x$ and $y$ are **coprime** (sometimes called relatively prime)
- The Euclidean algorithm is based around the fact:
- $gcd(r_0, r_1) = gcd(r_1, r_0 - r_1)$
- $gcd(r_0, r_1) = gcd(r_1, r_0 - r_1)$
![1646755531.png](img/1646755531.png)
- Computing $(x-y)\cdot gcd(r_0, r_1)$ is easier as its a smaller number
- Computing $(x-y)\cdot gcd(r_0, r_1)$ is easier as it's a smaller number
- Doing this repeatedly is slow, we can use $gcd(r_0,r_1) = gcd(r_1, r_0\space mod \space r_1)$
![1646755650.png](img/1646755650.png)
@@ -37,16 +37,16 @@ $r_0=q\cdot r_1 + r_2 \\57=4\cdot 12 + 9\\ r_1=q\cdot r_2 + r_3 \\ 12=1\cdot 9 +
![1646756075.png](img/1646756075.png)
#### Bezout’s Identity
#### Bézout’s Identity
- Bezout’s identity tells us that the greatest common divisor of two numbers can be expressed as the sum of multiples of these numbers
- Bézout’s identity tells us that the greatest common divisor of two numbers can be expressed as the sum of multiples of these numbers
- $gcd(r_0,r_1) = s\cdot r_0 + t\cdot r_1$
- e.g. $gcd(99,20)=-1\cdot 99+5\cdot 20=1$
- $gcd(141,50)=11\cdot 141+-31\cdot 50=1$
- e.g. $gcd(99,20)=-1\cdot 99+5\cdot 20=1$
- $gcd(141,50)=11\cdot 141+-31\cdot 50=1$
##### Extended Euclidean Algorithm
- The extended euclidean algorithm calculates the $gcd(r_0,r_1)$ as normal, and in addition calculates $s$ and $t$.
- The extended Euclidean algorithm calculates the $gcd(r_0,r_1)$ as normal, and in addition calculates $s$ and $t$.
| Euclidean Algorithm | Extended Euclidean Algorithm |
| ---------------------------------- | ------------------------------------------------------------ |
@@ -81,4 +81,3 @@ $$
$$
Where $t$ is our multiplicative inverse