From 5e3106e81be4340c8f280e1da464e3f79398c0db Mon Sep 17 00:00:00 2001 From: Suryapratap Singh Date: Tue, 7 Sep 2021 18:10:47 +0530 Subject: [PATCH] fix, self-contained gcd method --- Maths/CoPrimeCheck.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Maths/CoPrimeCheck.js b/Maths/CoPrimeCheck.js index b2fd848f4..11aa7b89b 100644 --- a/Maths/CoPrimeCheck.js +++ b/Maths/CoPrimeCheck.js @@ -9,8 +9,14 @@ is coprime with b. */ -// Here we require an already implemented method. -const GetEuclidGCD = require('./GetEuclidGCD') +// Here we use a GetEuclidGCD method as a utility. +const GetEuclidGCD = (arg1, arg2) => { + let less = arg1 > arg2 ? arg2 : arg1 + for (less; less >= 2; less--) { + if ((arg1 % less === 0) && (arg2 % less === 0)) return (less) + } + return (less) +} // CoPrimeCheck function return the boolean in respect of the given number is co-prime or not. /**