Skip to content

Commit e92e2e3

Browse files
committed
Added a short explanation of the Ext Euc Algo
1 parent 79c7ce4 commit e92e2e3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Maths/ExtendedEuclideanGCD.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@
22
* Problem statement and explanation: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
33
*
44
* This algorithm plays an important role for modular arithmetic, and by extension for cyptography algorithms
5-
*
6-
* This implementation uses an iterative approach to calculate
5+
*
6+
* Basic explanation:
7+
* The Extended Euclidean algorithm is a modification of the standard Euclidean GCD algorithm.
8+
* It allows to calculate coefficients x and y for the equation:
9+
* ax + by = gcd(a,b)
10+
*
11+
* This is called Bézout's identity and the coefficients are called Bézout coefficients
12+
*
13+
* The algorithm uses the Euclidean method of getting remainder:
14+
* r_i+1 = r_i-1 - qi*ri
15+
* and applies it to series s and t (with same quotient q at each stage)
16+
* When r_n reaches 0, the value r_n-1 gives the gcd, and s_n-1 and t_n-1 give the coefficients
17+
*
18+
* This implementation uses an iterative approach to calculate the values
719
*/
820

921
/**
@@ -57,4 +69,3 @@ const extendedEuclideanGCD = (arg1, arg2) => {
5769
}
5870

5971
export { extendedEuclideanGCD }
60-
// ex

0 commit comments

Comments
 (0)