fix, self-contained gcd method

This commit is contained in:
Suryapratap Singh
2021-09-07 18:10:47 +05:30
parent 5a8bb67124
commit 5e3106e81b

View File

@ -9,8 +9,14 @@
is coprime with b. is coprime with b.
*/ */
// Here we require an already implemented method. // Here we use a GetEuclidGCD method as a utility.
const GetEuclidGCD = require('./GetEuclidGCD') 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. // CoPrimeCheck function return the boolean in respect of the given number is co-prime or not.
/** /**