Skip to content

Commit e50f86a

Browse files
committed
GCD calc
1 parent d5a21b2 commit e50f86a

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

lib/lcm.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
21
const gcd = (a, b) => {
32
while (b != 0) {
4-
const h = a
5-
a = b
6-
b = h % b
7-
// (a, b) = (b, a % b)
3+
[a, b] = [b, a % b]
84
}
95
return Math.abs(a)
106
}
11-
12-
// const lcm = (a, b) => {
13-
// return (a / gcd(a, b)) * b
14-
// }
15-
167
export default (a, b) => {
178
return (a / gcd(a, b)) * b
189
}

0 commit comments

Comments
 (0)