iCalculator.
Math & statistics

Greatest common divisor calculator

Find the largest positive integer that divides both inputs.

Reviewed December 1, 2026

Your numbers

Calculations run in your browser. Your inputs stay on your device.

Your results

Enter your numbers and select Calculate.

The formula

Repeat gcd(a,b) = gcd(b, a mod b) until the second term is zero.

Worked example

The greatest common divisor of 48 and 18 is 6.

What to keep in mind

Negative inputs are treated by magnitude. This calculator uses gcd(0,0) = 0 by convention.

Formula sources