Jump to content

Least common multiple: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Reverted edits by 76.213.114.236 (talk) to last version by 62.108.160.100
Added a third method for computing the LCM and an external reference
Line 70: Line 70:


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.
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.

==A third method==

This method works as easily for finding the LCM of several integers.

Let there be a finite sequence of positive integers X = (x<sub>1</sub>, x<sub>2</sub>, ..., x<sub>n</sub>), n > 1. The algorithm proceeds in steps as follows: on each step m it examines and updates the sequence X<sup>(m)</sup> = (x<sub>1</sub><sup>(m)</sup>, x<sub>2</sub><sup>(m)</sup>, ..., x<sub>n</sub><sup>(m)</sup>), X<sup>(1)</sup> = X. The purpose of the examination is to pick up the least (perhaps, one of many) element of the sequence X<sup>(m)</sup>. Assuming x<sub>k<sub>0</sub></sub><sup>(m)</sup> is the selected element, the sequence X<sup>(m+1)</sup> is defined as

: x<sub>k</sub><sup>(m+1)</sup> = x<sub>k</sub><sup>(m)</sup>, k ≠ k<sub>0</sub>
: x<sub>k<sub>0</sub></sub><sup>(m+1)</sup> = x<sub>k<sub>0</sub></sub><sup>(m)</sup> + x<sub>k<sub>0</sub></sub>.

In other words, the least element is increased by the corresponding x whereas the rest of the elements pass from X<sup>(m)</sup> to X<sup>(m+1)</sup> unchanged.

The algorithm stops when all elements in sequence X<sup>(m)</sup> are equal. Their common value L is exactly LCM(X). (For a proof and an interactive simulation see reference below, ''Algorithm for Computing the LCM''.)


== The lcm in commutative rings ==
== The lcm in commutative rings ==
Line 86: Line 99:
* [http://www.utilitymill.com/utility/GCF_and_LCM_Calculator Online LCM calculator]
* [http://www.utilitymill.com/utility/GCF_and_LCM_Calculator Online LCM calculator]
* [http://www.kwiznet.com/p/takeQuiz.php?ChapterID=1460&CurriculumID=5 LCM Quiz]
* [http://www.kwiznet.com/p/takeQuiz.php?ChapterID=1460&CurriculumID=5 LCM Quiz]
* [http://www.cut-the-knot.org/Curriculum/Arithmetic/LCM.shtml Algorithm for Computing the LCM]



[[Category:elementary arithmetic]]
[[Category:elementary arithmetic]]

Revision as of 22:12, 28 June 2008

In arithmetic and number theory, the least common multiple or lowest common multiple (lcm) or smallest common multiple of two integers a and b is the smallest positive integer that is a multiple of both a and b. Since it is a multiple, it can be divided by a and b without a remainder. If there is no such positive integer, e.g., if a = 0 or b = 0, then lcm(a, b) is defined to be zero.

For example, the least common multiple of the numbers 4 and 6 is 12.

When adding or subtracting vulgar fractions, it is useful to find the least common multiple of the denominators, often called the lowest common denominator. For instance,

where the denominator 42 was used because lcm(21, 6) = 42.

Calculating the least common multiple

If a and b are not both zero, the least common multiple can be computed by using the greatest common divisor (gcd) of a and b:

Thus, the Euclidean algorithm for the gcd also gives us a fast algorithm for the lcm. To return to the example above,

Because (ab)/c = a(b/c) = (a/c)b, one can calculate the lcm using the above formula more efficiently, by first exploiting the fact that b/c or a/c will be easier to calculate than the quotient of the product ab and c, because the fact that c is a factor of both a and b entails that in either fraction, a/c or b/c, one can completely cancel the c. This can be true whether the calculations are performed by a human, or a computer, which may have storage requirements on the variables a, b, c, where the limits may be 4-byte storage - calculating ab may cause an overflow, if storage space is not allocated properly.

Using this, we can then calculate the lcm by either using:

or

Done this way, the previous example becomes:

Even if the numbers are large and not quickly factorable, the gcd can be calculated quickly with Euclid's algorithm.

Alternative method

The unique factorization theorem says that every positive integer number greater than 1 can be written in only one way as a product of prime numbers. The prime numbers can be considered as the atomic elements which, when combined together, make up a composite number.

For example:

Here we have the composite number 90 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 knowledge can be used to find the lcm of a set of numbers.

Example: Find the value of lcm(8,9,21).

First, factor out each number and express it as a product of prime number powers.

The lcm will be the product of multiplying the highest power in each prime factor category together. Out of the 4 prime factor categories 2, 3, 5, and 7, the highest powers from each are 23, 32, 50, and 71. Thus,

Viewing this method via Venn diagrams

One can find the least common multiple of two numbers by using a Venn diagram as follows. Find the prime factorization of each of the two numbers. Put the prime factors into a Venn diagram with one circle for each of the two numbers, and all factors they share in common in the intersection. To find the LCM, just multiply all of the prime numbers in the diagram.

Here is an example:

48 = 2 × 2 × 2 × 2 × 3,
180 = 2 × 2 × 3 × 3 × 5,

and what they share in common is two "2"s and a "3":

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.

A third method

This method works as easily for finding the LCM of several integers.

Let there be a finite sequence of positive integers X = (x1, x2, ..., xn), n > 1. The algorithm proceeds in steps as follows: on each step m it examines and updates the sequence X(m) = (x1(m), x2(m), ..., xn(m)), X(1) = X. The purpose of the examination is to pick up the least (perhaps, one of many) element of the sequence X(m). Assuming xk0(m) is the selected element, the sequence X(m+1) is defined as

xk(m+1) = xk(m), k ≠ k0
xk0(m+1) = xk0(m) + xk0.

In other words, the least element is increased by the corresponding x whereas the rest of the elements pass from X(m) to X(m+1) unchanged.

The algorithm stops when all elements in sequence X(m) are equal. Their common value L is exactly LCM(X). (For a proof and an interactive simulation see reference below, Algorithm for Computing the LCM.)

The lcm in commutative rings

The least common multiple can be defined generally over commutative rings as follows: Let a and b be elements of a commutative ring R. A common multiple of a and b is an element m of R such that both a and b divide m (i.e. there exist elements x and y of R such that ax = m and by = m). A least common multiple of a and b is a common multiple that is minimal in the sense that for any other common multiple n of a and b, m divides n.

In general, two elements in a commutative ring can have no least common multiple or more than one. However, any two least common multiples of the same pair of elements are associates. In a unique factorization domain, any two elements have a least common multiple. In a principal ideal domain, the least common multiple of a and b can be characterised as a generator of the intersection of the ideals generated by a and b (the intersection of a collection of ideals is always an ideal). In principal ideal domains, one can even talk about the least common multiple of arbitrary collections of elements: it is a generator of the intersection of the ideals generated by the elements of the collection.

See also