2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -0,0 +1,18 @@
|
|||
(() => {
|
||||
'use strict';
|
||||
|
||||
// gcd :: Integral a => a -> a -> a
|
||||
let gcd = (x, y) => {
|
||||
let _gcd = (a, b) => (b === 0 ? a : _gcd(b, a % b)),
|
||||
abs = Math.abs;
|
||||
return _gcd(abs(x), abs(y));
|
||||
}
|
||||
|
||||
// lcm :: Integral a => a -> a -> a
|
||||
let lcm = (x, y) =>
|
||||
x === 0 || y === 0 ? 0 : Math.abs(Math.floor(x / gcd(x, y)) * y);
|
||||
|
||||
// TEST
|
||||
return lcm(12, 18);
|
||||
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue