Enter 2 or more whole numbers separated by commas (,). You can find the GCF of 3 or more at once, and the prime factorization of each number and their common prime factors are shown too.
Table of Contents
-
What you can do on this page
-
What is this calculation used for?
-
How to Use
-
Formula
-
Symbols and terms
-
Good to know before you start
-
How to calculate it in Excel
-
How to calculate it in Google Sheets
-
How to calculate it in Python
-
How to write it in LaTeX and other math languages (copy and paste)
-
How to have ChatGPT do the calculation
-
DataChef Features
-
Related Features
-
NumberChef Calculators List
What you can do on this page
- Enter whole numbers separated by commas and get the greatest common factor (GCF, also called the GCD) on the spot
- Not just 2 numbers: find the GCF of 3 or more at once, such as "16, 88, 104"
- The prime factorization of each number and the prime factors they share are shown too, so you also learn how to find and check the answer
- A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
What is this calculation used for?
To simplify \(\frac{12}{18}\), divide the numerator and the denominator by their GCF, 6, and you get \(\frac{2}{3}\) in one step.
Instead of dividing by 2, then by 3 and so on, the GCF takes the fraction to simplest form at once. From elementary school math to everyday work, this is the most common use of the GCF.
You want to pack 24 cookies and 36 juice boxes into as many identical bags as possible, with nothing left over. The largest number of bags is \(\gcd(24, 36) = 12\), with 2 cookies and 3 juice boxes in each bag.
Making prize bags for a school fair or putting supplies into matching kits: this is the standard calculation for splitting different kinds of items into equal groups.
To cover a floor that is 84 inches by 108 inches (7 ft by 9 ft) with square tiles, with no gaps and no cutting, the largest tile you can use is \(\gcd(84, 108) = 12\), a 12-inch square tile (7 rows of 9 tiles).
Dividing a rectangle into the largest possible squares is used when tiling floors and walls, and when cutting cards of the same size from a large sheet of paper without waste.
If the tooth counts of two meshing gears have a large GCF, the same teeth hit each other again and again, and they wear unevenly. So in machine design, a basic rule is to make the tooth counts as close to relatively prime (GCF of 1) as possible.
The gears inside cars and clocks use this idea of keeping the GCF small.
RSA encryption, used for online shopping and online banking, needs to check whether two numbers are relatively prime while making its keys, and the Euclidean algorithm does that job.
A method for the GCF from more than 2,000 years ago now protects communication all over the world. It shows how long-lived mathematics can be.
Formula
Symbols and terms
Symbols
| \(\gcd(a, b)\) | G C D of a and b | The greatest common factor of \(a\) and \(b\). The symbol comes from "greatest common divisor" (GCD). US schools usually say greatest common factor (GCF) and may write \(\mathrm{GCF}(a, b)\), which is exactly the same thing. |
| \(a \bmod b\) | a mod b | The remainder when \(a\) is divided by \(b\). (Example - \(48 \bmod 18 = 12\), because 48 ÷ 18 = 2 R12) |
| \(\mathrm{lcm}(a, b)\) | L C M of a and b | The least common multiple of \(a\) and \(b\), from the first letters of "least common multiple". (Example - \(\mathrm{lcm}(12, 18) = 36\)) |
| \(p_1, p_2, \ldots\) | p sub 1, p sub 2, and so on | The common prime factors listed in order. The small lowered numbers (subscripts) only show first, second and so on. They are not used in the calculation. |
| \(\cdots\) | dots (ellipsis) | A symbol for "and so on, following the same pattern". Here it shows that you multiply the prime factors in the same way however many there are. |
Terms
| factor | A positive whole number that divides a whole number evenly. 12 has 6 factors - 1, 2, 3, 4, 6 and 12. |
| common factor | A factor shared by two or more whole numbers. The common factors of 12 and 18 are 1, 2, 3 and 6. Every common factor is a factor of the greatest common factor (6 here). |
| greatest common factor (GCF) | The largest of the common factors. US schools call it the greatest common factor (GCF). In higher math and programming it is usually called the greatest common divisor (GCD). Both are the same number. |
| prime number | A whole number of 2 or more whose only factors are 1 and itself - 2, 3, 5, 7, 11, 13, … 1 is not a prime number. |
| prime factorization | Writing a whole number as a product of prime numbers only. (Example - \(12 = 2 \times 2 \times 3\)) Each prime used is called a prime factor. |
| relatively prime | When the GCF of two whole numbers is 1 (their only common factor is 1). Like 17 and 13, they share no prime factors at all. Also called coprime. |
| Euclidean algorithm | A way to find the GCF by repeating "divide the larger number by the smaller one, and replace the pair with the smaller number and the remainder". It is taught in high school and college number theory and computer science. Known since ancient times, it is often called the oldest algorithm in the world. |
| least common multiple (LCM) | The smallest positive whole number that is a multiple of two or more whole numbers. It is used to find a common denominator for fractions. For two numbers, \(\gcd(a, b) \times \mathrm{lcm}(a, b) = a \times b\). |
Good to know before you start
Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back over these topics is the quickest way forward.
| Multiplication facts and division with remainders (Grades 3–4) |
|
| Factors and common factors (Grades 4–6) |
|
| Simplifying fractions (Grades 4–5) |
|
| Prime numbers and prime factorization (Grades 4–6) |
|
How to calculate it in Excel
| First number a | 12 |
| Second number b | 18 |
| GCF gcd(a, b) | =GCD(B1,B2) |
| Number 1 | 16 |
| Number 2 | 88 |
| Number 3 | 104 |
| GCF | =GCD(B1:B3) |
| Larger number a | 48 |
| Smaller number b | 18 |
| Remainder of a ÷ b (a mod b) | =MOD(B1,B2) |
| gcd(a, b) | =GCD(B1,B2) |
| gcd(b, remainder) (same as above) | =GCD(B2,B3) |
| First number a | 12 |
| Second number b | 18 |
| GCF gcd(a, b) | =GCD(B1,B2) |
| LCM lcm(a, b) | =LCM(B1,B2) |
| gcd × lcm | =B3*B4 |
| a × b (same as above) | =B1*B2 |
With a range, as in "=GCD(B1:B3)" in the second table, you can find the GCF of 3 or more numbers at once (B4 shows 8).
The third table checks the Euclidean algorithm. With the MOD function (the remainder), you can confirm that gcd(a, b) and gcd(b, remainder) are the same value (both 6).
In the fourth table, gcd × lcm and a × b both come to 216, which confirms the relationship with the LCM. Just replace the input numbers with your own.
How to calculate it in Google Sheets
| First number a | 12 |
| Second number b | 18 |
| GCF gcd(a, b) | =GCD(B1,B2) |
| Number 1 | 16 |
| Number 2 | 88 |
| Number 3 | 104 |
| GCF | =GCD(B1:B3) |
| Larger number a | 48 |
| Smaller number b | 18 |
| Remainder of a ÷ b (a mod b) | =MOD(B1,B2) |
| gcd(a, b) | =GCD(B1,B2) |
| gcd(b, remainder) (same as above) | =GCD(B2,B3) |
| First number a | 12 |
| Second number b | 18 |
| GCF gcd(a, b) | =GCD(B1,B2) |
| LCM lcm(a, b) | =LCM(B1,B2) |
| gcd × lcm | =B3*B4 |
| a × b (same as above) | =B1*B2 |
Copy the whole table, paste it into cell A1, and replace the input numbers with your own.
How to calculate it in Python
from math import gcd
from functools import reduce
numbers = [330, 75, 450, 225] # whole numbers to find the GCF of (any number of them)
greatest_common_divisor = reduce(gcd, numbers) # applies gcd two at a time from the start
print(f"GCF of {numbers}: {greatest_common_divisor}")
How to write it in LaTeX and other math languages (copy and paste)
gcd(a, b) = p₁ × p₂ × ⋯
\gcd(a, b) = p_1 \times p_2 \times \cdots
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>gcd</mi>
<mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>)</mo>
<mo>=</mo>
<msub><mi>p</mi><mn>1</mn></msub>
<mo>×</mo>
<msub><mi>p</mi><mn>2</mn></msub>
<mo>×</mo>
<mo>⋯</mo>
</mrow>
</math>
gcd(a, b) = p_1 xx p_2 xx cdots
GCD[a, b]
igcd(a, b);
g = gcd(a, b);
gcd(a, b) = p_1 × p_2 × ⋯
gcd(a, b) = gcd(b, a mod b)
\gcd(a, b) = \gcd(b,\ a \bmod b)
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>gcd</mi>
<mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>)</mo>
<mo>=</mo>
<mi>gcd</mi>
<mo>(</mo><mi>b</mi><mo>,</mo>
<mi>a</mi><mspace width="0.3em"/><mi>mod</mi><mspace width="0.3em"/><mi>b</mi>
<mo>)</mo>
</mrow>
</math>
gcd(a, b) = gcd(b, a mod b)
GCD[a, b] == GCD[b, Mod[a, b]]
igcd(a, b) = igcd(b, a mod b);
gcd(a, b) == gcd(b, mod(a, b))
gcd(a, b) = gcd(b, a mod b)
gcd(a, b, c) = gcd(gcd(a, b), c)
\gcd(a, b, c) = \gcd(\gcd(a, b),\ c)
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>gcd</mi>
<mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>,</mo><mi>c</mi><mo>)</mo>
<mo>=</mo>
<mi>gcd</mi>
<mo>(</mo>
<mi>gcd</mi>
<mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>)</mo>
<mo>,</mo><mi>c</mi>
<mo>)</mo>
</mrow>
</math>
gcd(a, b, c) = gcd(gcd(a, b), c)
GCD[a, b, c]
igcd(igcd(a, b), c);
g = gcd(gcd(a, b), c);
gcd(a, b, c) = gcd(gcd(a, b), c)
gcd(a, b) × lcm(a, b) = a × b
\gcd(a, b) \times \mathrm{lcm}(a, b) = a \times b
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>gcd</mi>
<mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>)</mo>
<mo>×</mo>
<mi>lcm</mi>
<mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>)</mo>
<mo>=</mo>
<mi>a</mi>
<mo>×</mo>
<mi>b</mi>
</mrow>
</math>
gcd(a, b) xx lcm(a, b) = a xx b
GCD[a, b]*LCM[a, b] == a*b
igcd(a, b)*ilcm(a, b) = a*b;
gcd(a, b)*lcm(a, b) == a*b
gcd(a, b) × lcm(a, b) = a × b
How to have ChatGPT do the calculation
You are a calculation assistant for whole numbers. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing). For the four whole numbers 330, 75, 450 and 225, find each of the following: 1. The greatest common factor (GCF) of the four numbers 2. The prime factorization of each number 3. The prime factors that all four numbers share Show the formulas you used and the numbers from the execution result.
How to Use
-
1Enter your numbersType the numbers you want to calculate with into the input fields
-
2CalculatePress the "Calculate" button
-
3Check the resultThe result appears on the spot. The same page also explains the idea behind the calculation and the formula
DataChef Features
No technical knowledge required.
Intuitive and user-friendly operation.
Can be used without registering personal information.
Automatic file deletion by clicking "download".
and rapid file conversion.
No attribution required.
No need to contact us for commercial use permission.
