GCF and LCM Calculator
Find the GCF, exact LCM and simplified ratio of two or three numbers, or a list of 2–20 integers.
Formula and sources updated · Data sources · 1View algorithm, constants and default inputs (JSON)
Division steps
Swipe horizontally to see more
| Verification |
|---|
| 24 = 0 × 36 + 24 |
| 36 = 1 × 24 + 12 |
| 24 = 2 × 12 + 0 |
Positive divisors (6)
1 · 2 · 3 · 4 · 6 · 12
About this calculator
Find the GCF, exact LCM and simplified ratio of two or three numbers, or a list of 2–20 integers. List mode uses absolute values. The optional third 0 is omitted only in two/three-number mode; zeros in a list are included. See Euclidean steps and all positive common factors. GCD and GCF name the same quantity. Choose GCF or LCM as the main result; their exact product is also available.
Worked example
calculated with the default values below
Results Greatest common factor · Input mode Two or three numbers · First number 24 · Second number 36 · Third number (0 to ignore) 0 · Numbers (2–20; spaces, commas or new lines) 24, 36, 60 Greatest common factor 12 · Least common multiple 72 · Simplified ratio 2 : 3 · Common factors 6 · Greatest common factor × Least common multiple 864
Method and assumptions
The Euclidean algorithm repeatedly divides and takes the remainder until it reaches zero; the last nonzero value is the GCF. For a list, repeat with each next number. Divide every input by the GCF to simplify the ratio. The positive common factors are the positive divisors of the GCF. LCM arithmetic uses exact integers, including results larger than the safe floating-point range. In pair mode a third value of 0 is omitted. In list mode zeros are included, so a list containing zero has LCM 0 unless the whole input is zero, which this tool rejects. Negative values are accepted only in list mode and are converted to absolute values.
Data sources
Disclaimer
These calculators give general mathematical results. They suit study, planning and estimation — verify anything that feeds a graded submission, a published figure or a financial commitment.
Implementation source
This record describes the implementation used by this page. It is not independent validation. External references, when available, support only the stated formula or definition; estimates and custom rules retain their own assumptions.
Formula and variables
g = gcd(|n₁|,…,|nₖ|); l = lcm(|n₁|,…,|nₖ|); ratio = |n₁|/g : … : |nₖ|/g; d(g) = Πᵢ(eᵢ + 1)
- A
- First number (≥ 0)
- B
- Second number (≥ 0)
- C
- third positive integer (0 = omit)
- g
- greatest common factor
- l
- least common multiple
- e_i
- exponent of prime factor i of g
- d(g)
- common-factor count
Find the GCF, exact LCM and simplified ratio of two or three numbers, or a list of 2–20 integers. List mode uses absolute values. The optional third 0 is omitted only in two/three-number mode; zeros in a list are included. See Euclidean steps and all positive common factors.
Frequently asked questions
How do zeros and negative numbers work?
Pair mode accepts nonnegative integers; its third 0 means “use only the first two numbers.” List mode accepts positive or negative integers and uses their absolute values. A zero in a list is included: for 24, 36, 0 the GCF is 12, LCM is 0 and ratio is 2 : 3 : 0. An all-zero input is rejected by this tool.
Does a very large LCM lose precision?
No. The LCM uses exact integer arithmetic and is shown in full, even beyond JavaScript’s safe Number range. The GCF, ratio and divisors remain available. Lists accept 2–20 integers with absolute value at most one billion, separated by spaces, commas, semicolons or new lines.
What do the division steps show?
The Euclidean algorithm repeatedly writes a = q × b + r until the remainder is zero. For a list it repeats this calculation between the running GCF and each next value. The positive common factors are the positive divisors of the final GCF.
How do I find the GCF and LCM of a list of numbers?
Choose list mode and enter 2–20 integers separated by spaces, commas, semicolons or new lines. For 24, 36, 60, the GCF is 12 and the LCM is 360. The tool also simplifies their ratio. An all-zero list has no defined GCF result here.
What input limits apply in the two modes?
Pair mode uses two required nonnegative integers and a third nonnegative field, each at most 1,000,000,000. Enter 0 in the third field to omit it. List mode accepts 2–20 integers, each with absolute value at most 1,000,000,000, separated by spaces, commas, semicolons or new lines. At least one included value must be nonzero.
What are the GCF, LCM and ratio of 24 and 36?
In pair mode enter 24 and 36, with third number 0 to omit it. The Euclidean steps are 36 = 1 × 24 + 12 and 24 = 2 × 12 + 0, so the GCF is 12. The LCM is 24 × 36 ÷ 12 = 72 and the simplified ratio is 2 : 3. Their six positive common factors are 1, 2, 3, 4, 6 and 12. The hidden list field does not participate in pair mode.