UNPKG

chinese-remainder

Version:

A lightweight NPM package for solving modular equations using the Chinese Remainder Theorem (CRT). Supports modular inverse, LCM, and GCD calculations.

10 lines (7 loc) 179 B
function lcm(a, b) { return Math.abs(a * b) / gcd(Math.abs(a), Math.abs(b)); } function gcd(a, b) { return b === 0 ? a : gcd(b, a % b); } module.exports = lcm;