This site is supported by donations to The OEIS Foundation.
LCM
From OeisWiki
The least common multiple (LCM or lcm) of one or more nonzero integers is the smallest positive integer that is a multiple of all those numbers. For example, the LCM of 12 and 14 is 84; no smaller multiple of 12 is also divisible by 14, nor is any smaller multiple of 14 also divisible by 12.
Contents |
GCD and LCM in terms of the prime factorization
From the prime factorization of
where
is the number of primes up to
, and
is the
th prime number, we have
and
Formulae
Formulae relating LCM to GCD
Since
then the least common multiple (LCM) of two nonzero integers
and
is related to their greatest common divisor (GCD) by
where the GCD may be obtained via the Euclidean algorithm.
The above formula results from the fact that
corresponds to multiset intersection of the two multisets (bags) of prime factors (with multiplicity), while
corresponds to multiset union (which amounts to multiset addition, here performed multiplicatively as
, minus bag intersection, here performed multiplicatively via division by
) of the two bags of prime factors (with multiplicity).
Since (using the inclusion-exclusion principle)
we then have
Finally, since (using the inclusion-exclusion principle)
we then have
Examples
- {{lcm|1}} = 1
- {{lcm|144}} = 144
- {{lcm|1|144}} = 144
- {{lcm|144|2988}} = 11952
- {{lcm|2988|37116}} = 3080628
- {{lcm|25|625}} = 625
- {{lcm|544|119}} = 3808
Sequences
A003418 a(0) = 1; for
, a(n) = least common multiple (or lcm) of {1, 2, ..., n}.
- {1, 1, 2, 6, 12, 60, 60, 420, 840, 2520, 2520, 27720, 27720, 360360, 360360, 360360, 720720, 12252240, 12252240, 232792560, 232792560, 232792560, 232792560, 5354228880, ...}
A002944 LCM{1, 2, ..., n} / n.
- {1, 1, 2, 3, 12, 10, 60, 105, 280, 252, 2520, 2310, 27720, 25740, 24024, 45045, 720720, 680680, 12252240, 11639628, 11085360, 10581480, 232792560, 223092870, 1070845776, ...}
A025527 a(n) = n! / LCM{1,2,...,n} = (n-1)! / LCM{C(n-1,0), C(n-1,1), ..., C(n-1,n-1)}.
- {1, 1, 1, 2, 2, 12, 12, 48, 144, 1440, 1440, 17280, 17280, 241920, 3628800, 29030400, 29030400, 522547200, 522547200, 10450944000, 219469824000, 4828336128000, 4828336128000, ...}
See also
- Greatest common divisor (GCD or gcd) and Euclidean algorithm
- {{gcd}} mathematical function template
- Least common multiple (LCM or lcm)
- {{lcm}} mathematical function template
