mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
Added a short explanation of the Ext Euc Algo
This commit is contained in:
@ -2,8 +2,20 @@
|
|||||||
* Problem statement and explanation: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
|
* Problem statement and explanation: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
|
||||||
*
|
*
|
||||||
* This algorithm plays an important role for modular arithmetic, and by extension for cyptography algorithms
|
* This algorithm plays an important role for modular arithmetic, and by extension for cyptography algorithms
|
||||||
*
|
*
|
||||||
* This implementation uses an iterative approach to calculate
|
* Basic explanation:
|
||||||
|
* The Extended Euclidean algorithm is a modification of the standard Euclidean GCD algorithm.
|
||||||
|
* It allows to calculate coefficients x and y for the equation:
|
||||||
|
* ax + by = gcd(a,b)
|
||||||
|
*
|
||||||
|
* This is called Bézout's identity and the coefficients are called Bézout coefficients
|
||||||
|
*
|
||||||
|
* The algorithm uses the Euclidean method of getting remainder:
|
||||||
|
* r_i+1 = r_i-1 - qi*ri
|
||||||
|
* and applies it to series s and t (with same quotient q at each stage)
|
||||||
|
* When r_n reaches 0, the value r_n-1 gives the gcd, and s_n-1 and t_n-1 give the coefficients
|
||||||
|
*
|
||||||
|
* This implementation uses an iterative approach to calculate the values
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,4 +69,3 @@ const extendedEuclideanGCD = (arg1, arg2) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export { extendedEuclideanGCD }
|
export { extendedEuclideanGCD }
|
||||||
// ex
|
|
||||||
|
Reference in New Issue
Block a user