- #1
0-RWHP
- 2
- 0
I know it's a really basic problem. I can find GCD with it but I can't find how to use the euclidean algorithm to find the LCM of two numbers? Sorry for the noob question :)
0-RWHP said:Oh ok, so with 8, 19 for example you would just do 8x19 then divide that by GCD of 8, 19. The GCD of 8, 19 is 1 so the answer is just 152 right? This is great, I loved when I discovered Euclids algorithm for GCD and was really excited when I found it could do LCM as well. Thanks so much for your help, I appreciate it.
Euclid's algorithm is a method used to find the greatest common divisor (GCD) of two integers. It is based on the principle that the GCD of two numbers is equal to the GCD of the smaller number and the remainder when the larger number is divided by the smaller number.
To find the GCD of two numbers using Euclid's algorithm, divide the larger number by the smaller number and find the remainder. Then, divide the smaller number by the remainder and find the new remainder. Repeat this process until the remainder is equal to 0. The last non-zero remainder is the GCD of the two numbers.
The LCM (least common multiple) of two numbers is equal to the product of the two numbers divided by their GCD. Therefore, you can use Euclid's algorithm to find the GCD of two numbers and then use this result to calculate the LCM.
Yes, Euclid's algorithm can be extended to find the GCD and LCM of more than two numbers. Simply apply the algorithm to the first two numbers, then use the result to find the GCD and LCM of this result and the next number, and continue until all numbers have been included.
While Euclid's algorithm is a commonly used and efficient method for finding the LCM, there are other algorithms that may be more efficient for specific types of numbers. For example, the binary GCD algorithm is faster for large numbers, and the sieve of Eratosthenes is more efficient for finding the LCM of a large set of numbers.