Skip to content

Commit 5e3106e

Browse files
fix, self-contained gcd method
1 parent 5a8bb67 commit 5e3106e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Maths/CoPrimeCheck.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
is coprime with b.
1010
*/
1111

12-
// Here we require an already implemented method.
13-
const GetEuclidGCD = require('./GetEuclidGCD')
12+
// Here we use a GetEuclidGCD method as a utility.
13+
const GetEuclidGCD = (arg1, arg2) => {
14+
let less = arg1 > arg2 ? arg2 : arg1
15+
for (less; less >= 2; less--) {
16+
if ((arg1 % less === 0) && (arg2 % less === 0)) return (less)
17+
}
18+
return (less)
19+
}
1420

1521
// CoPrimeCheck function return the boolean in respect of the given number is co-prime or not.
1622
/**

0 commit comments

Comments
 (0)