Skip to content

Instantly share code, notes, and snippets.

@martinheidegger
Created December 20, 2016 06:28
Show Gist options
  • Save martinheidegger/4951b047db7ab1ade54d5693c42959e9 to your computer and use it in GitHub Desktop.
Save martinheidegger/4951b047db7ab1ade54d5693c42959e9 to your computer and use it in GitHub Desktop.
Calculates the least common multiple of two numbers.
module.exports = (a, b) => {
let ax = a
let bx = b
while (ax != bx) {
if (ax < bx) {
ax += a
} else {
bx += b
}
}
return ax
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment