How the greatest common factor is calculated
Enter two whole numbers. The result is their greatest common factor: the largest whole number that divides both, after the signs are ignored.
The page uses the Euclidean algorithm. Replace the pair with the second number and the remainder, and repeat until the remainder is 0. The factor is the last non-zero remainder. The rows below are each number divided by that factor. 0 divided by the factor is 0. Both zeros have no result.
How to use this calculator
- Enter the first whole number.
- Enter the second whole number.
- Read the factor. The rows below are each number divided by that factor.
Euclidean step
d is the greatest common factor. a and b are the numbers after the signs are ignored. r is the remainder when a is divided by b.
Repeat with b and r until the remainder is 0. The factor is then b. If one number is 0, the factor is the other number.
Source
The greatest common divisor of two integers, which is this factor, is defined on the Wikipedia page on the greatest common divisor.
Worked examples
Example: 12 and 18
18 divided by 12 leaves remainder 6. 12 divided by 6 leaves remainder 0. The factor is 6. 12 ÷ 6 = 2 and 18 ÷ 6 = 3.
Example: 7 and 13
The only common factor is 1. 7 ÷ 1 = 7 and 13 ÷ 1 = 13.
What to keep in mind
Each number can be a whole number from −1,000,000,000,000 to 1,000,000,000,000. −12 and 18 have the same factor as 12 and 18, which is 6. 0 and 12 have factor 12. Completed results, including both numbers, can be stored in this browser’s local history and never leave your device. Clear them with the history Clear action or by clearing site data.
Common questions about the greatest common factor
What is the greatest common factor of 12 and 18?
6. The quotients are 2 and 3.
What if the numbers share no factor except 1?
The factor is 1. For 7 and 13, the quotients are 7 and 13.
What about 0?
0 and 12 have factor 12. The quotients are 0 and 1. 0 and 0 have no result.
Do signs matter?
No. −12 and 18 have factor 6, the same as 12 and 18.
What counts as a whole number?
An integer from −1,000,000,000,000 to 1,000,000,000,000. A decimal such as 1.5 has no result.
Does this calculator store my numbers?
Completed results can be saved in this browser’s local history, including both numbers. They stay on your device and are not sent to our servers or to analytics. Clear them with the history Clear action or by clearing site data.