Saturday, May 15, 2010

How do you find the least common multiple between two numbers?

Hello!


Suppose that the two numbers are both >=2 (if one of the numbers is 1, the problem is trivial). Then both have its unique decomposition into prime factors. If we find this decomposition, which is not simple for large numbers, then LCM must contain the maximum degrees of all prime factors from both numbers.


Consider an example. Let `a = 126,` `b = 108.` Then `a = 2^1*3^2*7,` `b = 2^2*3^3.` The maximum degrees are `2` for `2,` `3` for `3` and `1` for `7.` Hence `LCM(a,b) = 2^2*3^3*7 =756.`


Another method is to find the greatest common divisor (for example, using Euclidean algorithm) and use the fact that `a*b = LCM(a,b)*GCD(a,b).`

No comments:

Post a Comment

Thomas Jefferson's election in 1800 is sometimes called the Revolution of 1800. Why could it be described in this way?

Thomas Jefferson’s election in 1800 can be called the “Revolution of 1800” because it was the first time in America’s short history that pow...