How this calculator works
The greatest common factor is the largest positive integer dividing both numbers exactly. It is found with Euclid’s algorithm: replace the pair with the second number and the remainder of the division, and repeat until the remainder is zero. Negative signs are ignored, and when one number is zero the GCF is the other number’s absolute value.
Formula
gcf(a, b) = gcf(b, a mod b), repeated until the remainder is 0; the last non-zero value is the answer.
Worked example
For 12 and 18: gcf(12, 18) = gcf(18, 12) = gcf(12, 6) = gcf(6, 0) = 6. For 48 and 180 the GCF is 12.
Advertisement
Frequently asked questions
What is the difference between GCF and GCD?
None in meaning: greatest common divisor (GCD) is the standard textbook name and GCF is the classroom term. Both name the largest integer dividing the given numbers.
Can I enter zero or negatives?
Yes. gcf(0, 7) is 7, and gcf(-24, 36) is 12. Only two zeros together are rejected, since every positive integer divides zero and there is no greatest one.
Can the answer be larger than both numbers?
No. The greatest common factor is at most the smaller absolute value, and it equals that value when one number divides the other.