Skip to content

Commit 33129f0

Browse files
committed
Add Euclidean GCD algo
1 parent 1f0be4b commit 33129f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

JavaScript/9-gcd.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
const gcd = (a, b) => {
4+
if (b === 0) return a;
5+
return gcd(b, a % b);
6+
};
7+
8+
// const gcd = (a, b) => (b === 0 ? a : gcd(b, a % b));
9+
10+
console.log(gcd(12, 78));

0 commit comments

Comments
 (0)