The Wayback Machine - https://web.archive.org/web/20250206161815/https://www.geeksforgeeks.org/greatest-common-divisor-gcd/
Open In App

Greatest Common Divisor - GCD

Last Updated : 03 Dec, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

The Greatest Common Divisor (GCD) also known as the Highest Common Factor (HCF) is the greatest number that divides a set of numbers without leaving a remainder. For example: GCD of 12 and 18 is 6 as it divides both numbers and is the largest of all their factors.

The GCD of any two numbers is never negative or 0, and the least positive integer common to any two numbers is always 1.

Examples of GCD (Greatest Common Divisor)

12 and 18:
Divisors of 12 are 1, 2, 3, 4, 6 and 12
Divisors of 18 are 1, 3, 6, 9 and 18
The common Divisors are 1, 3 and 6. The greatest common divisor or GCD is 6

30 and 15:
Divisors of 30 are 1, 2, 3, 5, 15 and 30
Divisors of 15 are 1, 3, 5 and 15
The common Divisors are 1, 3, 5 and 15. The greatest common divisor or GCD is 15.

4 and 9:
Divisors of 4 are 1, 2 and 4
Divisors of 9 are 1, 3 and 9
There is only one common divisor 1. Hence GCD is 1.

GCD for Beginners

GCD for Aptitude Preparation

GCD Practice Questions

GCD for Programmers

GCD - FAQs

Are GCD and HCF same?

GCD is greatest common divisor and HCF is highest common factor. Both are same.

Are GCD and LCM same?

No, LCM stands for least common multiple. LCM of two numbers is smaller value that is divisible by both the two numbers. Whereas GCD is the highest common factor of two numbers, that can divide the two numbers evenly. Therefore, LCM and GCD are different.

How is GCD Calculated?

GCD of two numbers can be calculated using diffeerent methods listed in the article also the GCD can be calculated by using the LCM of the two numbers. The formula to calculate GCD using LCm is expressed as, GCD (a, b) = (a × b)/ LCM (a, b). This means if we know the two numbers and their LCM, we can easily find their GCD using this formula.

Can the Greatest Common Divisor be Negative?

No, the greatest common divisor cannot be negative as it represents the greatest common divisor of two positive integers. The least value of GCD can be 1 and not lesser than it. This proves the point that GCD cannot hold a negative value.

What is the GCD of 24 and 36?

GCD of 24 and 36 is 2 × 2 × 3 = 12.

What is the GCD of 36 and 72?

There are 9 common factors of 36 and 72, that are 1, 2, 3, 4, 36, 6, 9, 12, and 18. Therefore, the gcd of 36 and 72 is 36.


Next Article

Similar Reads

three90RightbarBannerImg