![]() |
VOOZH | about |
The following are simple steps to find GCD of two numbers a and b.
- Step 1: List all the divisors of the number 'a'.
- Step 2: List all the divisors of the number 'b'.
- Step 3: Identify the common divisors of both 'a' and 'b'.
- Step 4: Select the largest number from the common divisors.
Let's consider an example for better understanding.
Example: Find the GCD of 13 and 48.
To solve the GCD of 13 and 48, we will first find:
- Divisors of 13: 1, 13
- Divisors of 48: 1, 2, 3, 4, 6, 8, 12, 16, 24, 48
The only common divisor of 13 and 48 is 1. Therefore, the GCD of 13 and 48 is 1.
So, GCD(13, 48) = 1.
There are multiple methods to find the Greatest Common Divisor (GCD) such as:
The prime factorization method involves breaking each number down into its prime factors (prime numbers that multiply to give the original number). The GCD is found by taking the product of the lowest powers of all common prime factors.
Note: This method works only for positive numbers (natural numbers).
👁 gcdExample: Find the GCD of 24, 30, and 36.
Solution:
To find the GCD of 24, 30, and 36, we need to find the:
- Prime factors of 24 = 23 × 3
- Prime factors of 30 = 2 × 3 × 5
- Prime factors of 36 = 22 × 32
The common prime factors are 2 and 3, and their smallest powers are 21 and 31.
So, the GCD of 24, 30, and 36 is:
This method uses the Euclid's Division Algorithm that works for positive integers and follows these steps:
This algorithm is efficient and works well for large numbers.
For example, we want to find GCD of 12 and 56.
GCD of 0 and a Positive Integer: GCD of a positive integer x and 0 is always x because x is the largest number that divides both x and 0. For example GCD of 0 and 5 is 5, GCD of 0 and 100 is 100.
Stein's algorithm or binary GCD algorithm method uses binary operations (shifting and comparison) and is efficient for computers. In this algorithm, we can use the following steps to find GCD:
Let's consider an example for better understanding.
Step 1: Both 18 and 24 are even, so divide both by 2 and multiply the result by 2: GCD(18, 24) = 2 × GCD(18/2, 24/2) = 2 × GCD(9, 12)
Step 2: 9 is odd and 12 is even, so divide 12 by 2: GCD(9, 12) = GCD(9, 12/2) = GCD(9, 6)
Step 3: 9 is odd and 6 is even, so divide 6 by 2: GCD(9, 6) = GCD(9, 6/2) = GCD(9, 3)
Step 4: Both 9 and 3 are odd, so subtract the smaller from the larger: GCD(9, 3) = GCD(9 − 3, 3) = GCD(6, 3)
Step 5: 6 is even, so divide by 2: GCD(6, 3) = GCD(6/2, 3) = GCD(3, 3)
Step 6: Both numbers are equal (3), so the GCD is 3.
Final Step: Multiply back the factor of 2 from Step 1: gcd(18, 24) = 2 × 3 = 6
Thus, GCD(18, 24) = 6.
Read More about Program for Stein's algorithm or binary GCD.