-
Couldn't load subscription status.
- Fork 2
Euclidean and Extended Euclidean for GCD
Rafiul Islam edited this page Nov 24, 2018
·
5 revisions
- if
a get 0then stop iteration and pickbas GCD
a = b % a |
b = a |
|---|---|
16 % 81 = 16
|
81 |
81 % 16 = 1
|
16 |
16 % 1 = 0
|
1 |
Extended Euclidean algorithm is a reverse process of Euclidean algorithm. It says: ax + by = GCD(p,q)
| p | q | t = q / p
|
a1 | a2 | a = a1-t*a2
|
b1 | b2 | b = b1-t*b2
|
|---|---|---|---|---|---|---|---|---|
| 16 | 81 | 5 | 1 | 0 | 1 | 0 | 1 | -5 |
| 1 | 16 | 16 | 0 | 1 | -16 | 1 | -5 | 81 |
0 |
1 |