LCM & GCF Calculator
This calculator finds the greatest common factor and least common multiple of two to twenty nonnegative whole numbers. It applies Euclid’s algorithm for common factors and uses exact integer arithmetic to build the common multiple without floating-point rounding.
By Dr. Hassan Khames EliwaLast updated
Result
How it works
Two different ways to combine divisibility
The greatest common factor, also called the greatest common divisor, is the largest positive integer dividing every nonzero entry without a remainder. It answers a grouping question: what is the largest equal-sized group that can divide all these quantities? The least common multiple answers a synchronization question: what is the smallest positive quantity divisible by every positive entry?
For two positive integers a and b, GCF can be found by repeatedly replacing the pair with b and the remainder of a divided by b until the remainder is zero. This is Euclid’s algorithm. The LCM then follows from (a ÷ GCF) × b. Dividing before multiplying keeps intermediate expressions smaller. For more than two inputs, the calculator combines the running result with each subsequent entry.
Input and zero conventions
Enter between two and twenty whole numbers separated by spaces or commas. Each number must be nonnegative and at most one billion. Do not use commas as thousands separators inside a number: here a comma separates list entries. Decimal points, negative signs, and scientific notation are rejected because the input grammar intentionally describes whole-number lists rather than general numeric expressions.
The running calculations use JavaScript BigInt values. This matters because the LCM of individually modest integers can exceed the largest exactly represented ordinary JavaScript integer. Results are emitted as complete integer strings, not rounded scientific notation. If any input is zero, the LCM is defined here as zero. GCF with zero preserves the other number, and the all-zero list returns zero by convention rather than claiming a largest positive common divisor exists.
Worked example
Example 1: repeat two maintenance intervals
Two activities repeat every 12 and 18 days from a shared starting point. Enter 12,18. The calculator returns GCF 6 and LCM 36. Six is the largest whole-number unit that divides both interval lengths. Thirty-six days is the first positive interval at which the cycles coincide again, assuming both really repeat at fixed intervals and start together.
Example 2: coordinate three repeating tasks
For intervals of 8, 12, and 20 units, enter 8 12 20. The output is GCF 4 and LCM 120. First combining eight and twelve gives an LCM of 24; combining 24 with 20 gives 120. The common factor across all three remains four. These are arithmetic interval results, not calendar dates: months of unequal length and shifted working-day rules require a separate scheduling model.
Expert tips
Common mistakes
- The greatest common factor must divide every entry. Choosing the largest input skips that test; with positive entries, the factor cannot exceed the smallest of them.
- Multiplying the inputs can produce a common multiple without producing the least one. Shared factors are often counted repeatedly, making the product unnecessarily large.
- Decimal measurements need a stated common unit before they can be treated as whole-number counts. Record that conversion alongside the result so its meaning survives when the calculation is shared.
Frequently asked questions
Are GCF and GCD the same thing?
Yes. Greatest common factor and greatest common divisor name the same integer quantity. Different textbooks and programming libraries tend to prefer one abbreviation or the other.
Can I include zero?
Yes. The zero conventions are GCF(a, 0) = a and LCM(a, 0) = 0 for nonnegative a. An all-zero list returns zero for both outputs as an explicit computational convention.
Can the inputs be prime numbers?
Yes. Distinct primes have a GCF of one, and their LCM is their product. Repeated prime entries do not require repeating that prime factor in the LCM beyond its greatest needed exponent.
Why does a very large result show every digit?
The calculations use BigInt arithmetic and convert the result directly to an integer string. This avoids rounding the LCM through the ordinary floating-point number format.
How is this useful for fractions?
A common denominator can be built using the LCM of denominators, while a numerator and denominator can be reduced using their GCF. The fraction calculator handles the accompanying fraction arithmetic.
Related calculators
Related guides
MathPercentages people get wrong: change, difference and pointsThe denominator determines the answer. Learn to distinguish percentage change, symmetric difference and percentage-point movements.14 November 2026 · 7 min read
MathStandard deviation without the jargonThe average tells you the centre. Standard deviation helps describe the spread, provided you know what the data represents.14 November 2026 · 7 min readSources and standards
About the author
Dr. Hassan Khames Eliwa holds a PhD in Construction & Built Environment and has more than 20 years of international project controls experience. He is Director of Eliwa Project Controls Limited in Auckland and founder of PMMilestone.org and PMMilestone.com.
Buy me a coffee