Greatest Common Divisor (GCD)

Compute the GCD of two positive integers using the Euclidean algorithm — matching the layout of our conversion calculators.

Positive integer

Positive integer

How it works

The Euclidean algorithm repeatedly replaces the larger number by its remainder when divided by the smaller number until one side reaches zero. The last non-zero value is the GCD.


The Formula
gcd(a, b) = gcd(b, a mod b), with gcd(a, 0) = |a|.
For coprime numbers, gcd = 1.

Worked Example
  1. Example: GCD of 48 and 18

    48 = 18 × 2 + 12 → gcd(48,18)=gcd(18,12). 18 = 12 × 1 + 6 → gcd(12,6). 12 = 6 × 2 + 0 → gcd is 6.


Tips, Assumptions & Limitations
  • Both inputs must be positive integers.
  • Need LCM as well? Use the LCM & HCF calculator below.
FAQ

The greatest common divisor (GCD), also called greatest common factor (GCF), is the largest positive integer that divides both numbers without a remainder.

For two positive integers a and b: GCD(a,b) × LCM(a,b) = a × b. Use the LCM & HCF calculator when you need both values.

Companion article

GCD Calculator: Find the Greatest Common Divisor

Related Calculators
EmailLinkedInFacebook

© 2026 PromathTools. All rights reserved.

Developed by kruskalcode.com