Skip to content
ToolsLeb ToolsLeb

GCD Calculator

Calculate the Greatest Common Divisor of two numbers.

Simple Math

Calculator Inputs

Your Result

Enter your details and press Calculate to see your result.

Formula

GCD = Gcd(First Number, Second Number)
First Number
Second Number

How it works

  1. Enter two whole numbers.
  2. View their Greatest Common Divisor (GCD).

Share on Social Media:

Enter two whole numbers and the GCD Calculator returns their greatest common divisor: the largest number that divides both exactly. It's calculated with the Euclidean algorithm, so the answer is instant for any whole numbers up to about 9 quintillion (the 64-bit integer limit). You can copy the result, save it, or download it as CSV or PDF.

Worked example: GCD of 48 and 18

The Euclidean algorithm repeatedly replaces the larger number with the remainder after dividing by the smaller one:

  1. 48 ÷ 18 = 2 remainder 12
  2. 18 ÷ 12 = 1 remainder 6
  3. 12 ÷ 6 = 2 remainder 0

When the remainder reaches 0, the last non-zero remainder, 6, is the GCD. You can check: 48 = 6 × 8 and 18 = 6 × 3, and 8 and 3 share no common factor.

This method appears in Euclid's Elements (around 300 BC) and is still how computers calculate the GCD today. It's fast because the numbers shrink very quickly: even for numbers with hundreds of digits, it needs only a few hundred steps.

The other method: prime factors

At school you may have found the GCD by breaking numbers into primes:

  • 48 = 2 × 2 × 2 × 2 × 3
  • 18 = 2 × 3 × 3

Take the primes they share, as many times as both contain them: one 2 and one 3, so the GCD is 2 × 3 = 6. This is easy for small numbers, but factorising large numbers is very slow. That difficulty is what RSA encryption relies on. The Euclidean algorithm avoids factorising altogether.

Everyday uses

  • Simplifying fractions. Divide top and bottom by the GCD: 48/18 ÷ 6 = 8/3.
  • Simplifying ratios. A 1920 × 1080 screen has a GCD of 120, giving the familiar 16:9 aspect ratio.
  • Splitting things evenly. With 48 red and 18 blue tiles, the largest number of identical groups you can make is 6, each with 8 red and 3 blue.
  • Finding the LCM. For two numbers, LCM = (a × b) ÷ GCD. For 48 and 18: 864 ÷ 6 = 144.

Useful facts

  • If the GCD is 1, the numbers are coprime (e.g. 8 and 15), even though neither is prime.
  • GCD(a, 0) = a, because every number divides 0.
  • For more than two numbers, work in pairs: GCD(a, b, c) = GCD(GCD(a, b), c).
  • The GCD is the same whether the numbers are positive or negative, so it's always given as a positive number.

Frequently Asked Questions

Greatest Common Divisor — the largest number that divides evenly into two or more numbers.

Commonly via the Euclidean algorithm, which repeatedly divides and takes remainders until reaching zero — this tool computes that instantly for any numbers you enter.

Simplifying fractions to lowest terms, solving certain math problems, and in computer science for tasks like cryptography and scheduling.

GCD is the largest number that divides both numbers evenly, while LCM (Least Common Multiple) is the smallest number that both numbers divide into evenly — related but opposite concepts.

It repeatedly replaces the larger number with the remainder of dividing it by the smaller number, until the remainder is 0 — the last non-zero remainder is the GCD. This is one of the oldest known algorithms, dating back over 2,000 years.

The GCD of two different prime numbers is always 1, since primes have no divisors in common other than 1.

Dividing both the numerator and denominator of a fraction by their GCD reduces it to lowest terms — for example, 12/18 simplifies to 2/3 by dividing both by their GCD of 6.