From e92e2e39263b57ab589667722655455e3e956982 Mon Sep 17 00:00:00 2001 From: VinWare <28603906+VinWare@users.noreply.github.com> Date: Thu, 21 Oct 2021 18:31:39 +0530 Subject: [PATCH] Added a short explanation of the Ext Euc Algo --- Maths/ExtendedEuclideanGCD.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Maths/ExtendedEuclideanGCD.js b/Maths/ExtendedEuclideanGCD.js index 4e01ea59b..a5623b18c 100644 --- a/Maths/ExtendedEuclideanGCD.js +++ b/Maths/ExtendedEuclideanGCD.js @@ -2,8 +2,20 @@ * 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 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 } -// ex