Skip to content

Instantly share code, notes, and snippets.

@e-mihaylin
Created September 24, 2018 13:38
Show Gist options
  • Save e-mihaylin/053f2bdc3e9ea017b8a491b2da080edd to your computer and use it in GitHub Desktop.
Save e-mihaylin/053f2bdc3e9ea017b8a491b2da080edd to your computer and use it in GitHub Desktop.
const gcd = (a, b) => a ? gcd(b % a, a) : b;
const lcm = (a, b) => a * b / gcd(a, b);
[1, 2, 3, 4, 5].reduce(lcm); // Returns 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment