Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Least common multiple
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Calculation == There are several ways to compute least common multiples. === Using the greatest common divisor === The least common multiple can be computed from the [[greatest common divisor]] (gcd) with the formula :<math>\operatorname{lcm}(a,b)=\frac{|ab|}{\gcd(a,b)}.</math> To avoid introducing integers that are larger than the result, it is convenient to use the equivalent formulas :<math>\operatorname{lcm}(a,b)=|a|\,\frac{|b|}{\gcd(a,b)} = |b|\,\frac{|a|}{\gcd(a,b)} ,</math> where the result of the division is always an integer. These formulas are also valid when exactly one of {{math|''a''}} and {{math|''b''}} is {{math|0}}, since {{math|1=gcd(''a'', 0) = {{abs|''a''}}}}. However, if both {{math|''a''}}{{math|}} and {{math|''b''}} are {{math|0}}, these formulas would cause [[division by zero]]; so, {{math|1=lcm(0, 0) = 0}} must be considered as a special case. To return to the example above, :<math>\operatorname{lcm}(21,6) =6\times\frac {21}{\gcd(21,6)} =6\times\frac {21} 3 =6\times 7 = 42. </math> There are fast [[algorithm]]s, such as the [[Euclidean algorithm]] for computing the gcd that do not require the numbers to be [[Integer factorization|factored]]. For very large integers, there are even faster algorithms for the three involved operations (multiplication, gcd, and division); see [[Fast multiplication]]. As these algorithms are more efficient with factors of similar size, it is more efficient to divide the largest argument of the lcm by the gcd of the arguments, as in the example above. === Using prime factorization === The [[fundamental theorem of arithmetic|unique factorization theorem]] indicates that every positive integer greater than 1 can be written in only one way as a product of [[prime number]]s. The prime numbers can be considered as the atomic elements which, when combined, make up a [[composite number]]. For example: :<math>90 = 2^1 \cdot 3^2 \cdot 5^1 = 2 \cdot 3 \cdot 3 \cdot 5. </math> Here, the composite number 90 is made up of one atom of the prime number 2, two atoms of the prime number 3, and one atom of the prime number 5. This fact can be used to find the lcm of a set of numbers. Example: lcm(8,9,21) Factor each number and express it as a product of prime number [[Power (mathematics)|powers]]. : <math> \begin{align} 8 & = 2^3 \\ 9 & = 3^2 \\ 21 & = 3^1 \cdot 7^1 \end{align} </math> The lcm will be the product of multiplying the highest power of each prime number together. The highest power of the three prime numbers 2, 3, and 7 is 2<sup>3</sup>, 3<sup>2</sup>, and 7<sup>1</sup>, respectively. Thus, :<math>\operatorname{lcm}(8,9,21) = 2^3 \cdot 3^2 \cdot 7^1 = 8 \cdot 9 \cdot 7 = 504. </math> This method is not as efficient as reducing to the greatest common divisor, since there is no known general efficient algorithm for [[integer factorization]]. The same method can also be illustrated with a [[Venn diagram]] as follows, with the [[prime factorization]] of each of the two numbers demonstrated in each circle and ''all'' factors they share in common in the intersection. The lcm then can be found by multiplying all of the prime numbers in the diagram. Here is an example: : 48 = 2 Γ 2 Γ 2 Γ 2 Γ 3, : 180 = 2 Γ 2 Γ 3 Γ 3 Γ 5, sharing two "2"s and a "3" in common: :[[Image:least common multiple.svg|400px]] : Least common multiple = 2 Γ 2 Γ 2 Γ 2 Γ 3 Γ 3 Γ 5 = 720 : Greatest common divisor = 2 Γ 2 Γ 3 = 12 : Product = 2 Γ 2 Γ 2 Γ 2 Γ 3 Γ 2 Γ 2 Γ 3 Γ 3 Γ 5 = 8640 This also works for the [[greatest common divisor]] (gcd), except that instead of multiplying all of the numbers in the Venn diagram, one multiplies only the prime factors that are in the intersection. Thus the gcd of 48 and 180 is 2 Γ 2 Γ 3 = 12.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)