MMC de Dois Números
Calcula mínimo múltiplo comum (MMC) de dois inteiros: |a·b| / mdc(a,b).
MMC(a,b)
—
LCM of two numbers: formula and worked example
For two positive integers, the least common multiple is lcm(a, b) = (a · b) / gcd(a, b). The Euclidean algorithm finds the GCD in O(log min(a, b)), and the LCM falls out right after, so the whole thing stays logarithmic.
You can also work it from the prime factorisation: take each prime that shows up in either number and keep its highest exponent. Say 12 = 2² · 3 and 18 = 2 · 3². That gives lcm(12, 18) = 2² · 3² = 36.
Applications
- Adding fractions that have different denominators, where the common denominator is the LCM.
- Synchronising cyclic events such as traffic lights, periodic schedules and signal rotations.
- Working out the period at which two periodic functions line up again.
- LCM across a whole set, which you just chain pairwise, since
lcm(a, b, c) = lcm(lcm(a, b), c).
FAQ
Why divide by the GCD? The product a · b ends up counting every shared prime factor twice. Dividing by gcd(a, b) cancels that duplication out.
What if the numbers are coprime? With gcd(a, b) = 1 there's nothing to cancel, so the LCM is just the product a · b.
And if one of them is zero? The convention is lcm(0, n) = 0, because zero counts as a multiple of every integer.
Related Tools
Rent Adjustment Calculator
Compute annual rent adjustment by IGP-M or IPCA accumulated in the last 12 months (manually configurable).
Pregnancy Calculator
Compute estimated due date (EDD), gestational age and trimester from the last menstrual period (LMP).
Fertile Period Calculator
Compute fertile window and ovulation day from the first day of the last cycle and the average cycle length.