greatest common divisor calculator

GCD Calculator

Enter two or more integers (comma or space separated) to find their greatest common divisor instantly.

Tip: You can enter negative numbers too. The calculator uses absolute values for GCD.

What is the greatest common divisor?

The greatest common divisor (GCD), also called the greatest common factor (GCF), is the largest positive integer that divides two or more integers without leaving a remainder.

For example, the common divisors of 24 and 36 are 1, 2, 3, 4, 6, and 12. The greatest one is 12, so:

GCD(24, 36) = 12

How to use this greatest common divisor calculator

  • Type at least two integers in the input box.
  • Separate values with commas or spaces.
  • Click Calculate GCD to get the answer.
  • Review the Euclidean algorithm steps shown in the result panel.

This tool works well for homework checks, quick simplifications, and number theory practice.

How the Euclidean algorithm works

This calculator uses the classic Euclidean algorithm, which is fast and reliable even for large integers.

Core idea

For two integers a and b with a ≥ b, repeatedly replace the pair with:

(a, b) → (b, a mod b)

When the remainder becomes 0, the current non-zero value is the GCD.

Example: GCD(84, 126)

  • 126 = 84 × 1 + 42
  • 84 = 42 × 2 + 0

Since the remainder is now zero, GCD(84, 126) = 42.

Why GCD is useful

The greatest common divisor appears in many practical and academic settings:

  • Simplifying fractions: Divide numerator and denominator by their GCD.
  • Ratio reduction: Convert values to lowest terms.
  • Modular arithmetic: Essential in cryptography and algorithms.
  • Problem solving: Used in tiling, grouping, scheduling, and optimization tasks.
  • Programming interviews: A common test of algorithmic reasoning.

GCD for more than two numbers

To find the GCD of several values, compute it step by step:

GCD(a, b, c) = GCD(GCD(a, b), c)

Example:

  • GCD(48, 180) = 12
  • GCD(12, 300) = 12

So GCD(48, 180, 300) = 12.

Special cases to know

  • GCD(a, 0) = |a| for any integer a.
  • GCD(0, 0) is sometimes treated as undefined in pure math; this calculator returns 0 for practicality.
  • Negative signs do not affect the final GCD value, because divisibility depends on magnitude.

GCD vs LCM (quick comparison)

People often mix these up:

  • GCD: largest common divisor.
  • LCM: smallest common multiple.

For two non-zero integers, they are related by:

GCD(a, b) × LCM(a, b) = |a × b|

Frequently asked questions

Can I use decimal numbers?

This calculator is designed for integers only. If you have decimals, convert them to integers first when possible.

Can I enter negative values?

Yes. The tool accepts negative integers and computes the GCD using absolute values.

How large can numbers be?

The calculator supports safe JavaScript integers. Extremely huge values beyond safe integer range should be handled with specialized big-integer tools.

Final thoughts

A good greatest common divisor calculator should be accurate, simple, and transparent. This one gives you both the final GCD and the step-by-step reasoning, so you can trust the answer and learn from it at the same time.

🔗 Related Calculators