1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 1 5 5 3 3 13 13 13 3 2 1 1 10 5 | /* vim: set et sw=2 ts=2: */ 'use strict'; module.exports = function () { var Nodash = this; return { gcd: function (a, b) { var c; while (b !== 0) { c = Nodash.rem(a, b); a = b; b = c; } return a; }, lcm: function (a, b) { if (a === 0 || b === 0) { return 0; } return Math.abs(Nodash.quot(a, Nodash.gcd(a, b)) * b); }, even: function (x) { return (x % 2) === 0; }, odd: function (x) { return (x % 2) !== 0; } }; }; |