Greatest Common Divisor (GCD) Calculator
Repeat:
a = b, b = a % b
Until b = 0
Then GCD = a
Example:
Numbers: 48 and 18
Step 1: 48 % 18 = 12
Step 2: 18 % 12 = 6
Step 3: 12 % 6 = 0 โ GCD = 6
๐ข Greatest Common Divisor (GCD) Calculator
A GCD Calculator helps you quickly find the greatest common divisor (also known as the greatest common factor (GCF)) of two or more integers. Itโs widely used in arithmetic, algebra, number theory, and simplifying fractions.
๐ What Is the Greatest Common Divisor?
The Greatest Common Divisor (GCD) of two or more integers is the largest number that divides each of them exactly (without leaving a remainder).
๐ GCD Formula & Methods
๐น 1. Prime Factorization Method
Break each number into prime factors and multiply the common factors.
Example:
GCD of 18 and 24
โ 18 = 2 ร 3ยฒ
โ 24 = 2ยณ ร 3
โ GCD = 2 ร 3 = 6
๐น 2. Euclidean Algorithm
Keep replacing the larger number by its remainder with the smaller one until you get 0.
Example:
GCD(48, 18)
โ 48 รท 18 = 2 remainder 12
โ 18 รท 12 = 1 remainder 6
โ 12 รท 6 = 2 remainder 0
โ
GCD = 6
๐น 3. Using Built-in Functions
In programming languages:
- Python:
math.gcd(a, b) - Excel:
=GCD(a, b)
โ GCD Examples
| Numbers | GCD |
|---|---|
| 8, 12 | 4 |
| 36, 60 | 12 |
| 101, 103 | 1 |
| 0, 18 | 18 |
| 0, 0 | Undefined or 0 (context-dependent) |
๐งฎ Why Use a GCD Calculator?
- To simplify fractions (e.g., reduce 18/24 โ 3/4)
- In cryptography (e.g., RSA key generation)
- To solve Diophantine equations
- For scheduling and recurrence problems
โ FAQs โ Greatest Common Divisor Calculator
๐น What is the GCD of 0 and any number?
The GCD of 0 and any non-zero number n is n.
GCD(0, 7) = 7
๐น Can the GCD be negative?
No. GCD is always expressed as a positive integer, even if the original numbers are negative.
๐น What if all numbers are 0?
GCD(0, 0) is undefined or defined as 0 by some conventions.
๐น Is GCD the same as HCF?
Yes โ GCD (Greatest Common Divisor) and HCF (Highest Common Factor) are the same.
๐น What is the GCD of prime numbers?
If the numbers are different primes, their GCD is 1.