Skip to content
This repository was archived by the owner on Sep 7, 2025. It is now read-only.

Commit 823ea17

Browse files
whoisnpabranhe
authored andcommitted
added euclideanAlgorithm and iterative euclidean
1 parent 27e64eb commit 823ea17

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

algorithms/math/euclidean.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function euclideanAlgorithm(originalA, originalB) {
2+
const a = Math.abs(originalA);
3+
const b = Math.abs(originalB);
4+
5+
return b === 0 ? a : euclideanAlgorithm(b, a % b);
6+
}
7+
8+
var gcd = euclideanAlgorithm(1, 3);
9+
console.log(gcd);

0 commit comments

Comments
 (0)