GCD & LCM Calculator

Inputs

Enter numbers
Note: decimals are truncated toward 0 (e.g., 3.9 → 3). (Max 10 numbers)
Examples:

Results

Summary

GCD (HCF)
6
LCM
36
How GCD is found (prime factors)
Highlights show common prime powers (minimum exponents across all non-zero numbers).
12
2^23
18
23^2
Common prime powers
23
GCD = 2 × 3 = 6
How LCM is found (prime factors)
Uses maximum prime exponents across all non-zero numbers. If any input is 0, LCM = 0.
12
2^23
18
23^2
Max prime powers
2^23^2
LCM = 2^2 × 3^2 = 36
Tip: 2^5 means 2×2×2×2×2.

What is GCD (HCF)?

The Greatest Common Divisor (GCD) — also called the Highest Common Factor (HCF) — is the largest number that divides two or more numbers without leaving a remainder.

Example
GCD(12, 18) = 6
Because 6 divides both 12 and 18 exactly.
When is GCD used?
  • Simplifying fractions (e.g., 12/18 → 2/3)
  • Reducing ratios (e.g., 20:30 → 2:3)
  • Dividing items equally into groups
  • Finding common factors in algebra

What is LCM?

The Least Common Multiple (LCM) is the smallest positive number that is a multiple of two or more numbers.

Example
LCM(4, 6) = 12
Because 12 is the smallest number divisible by both 4 and 6.
When is LCM used?
  • Adding or subtracting fractions
  • Synchronizing cycles or schedules
  • Time & work problems
  • Finding a common denominator

Difference between GCD and LCM

FeatureGCD (HCF)LCM
MeaningGreatest common divisorLeast common multiple
PurposeSimplificationAlignment
Common useReducing fractions, ratiosAdding fractions, schedules
Result sizeUsually smallerUsually larger
Example (12, 18)636

How this calculator works

This calculator lets you:

  • Enter 2 or more numbers
  • Instantly compute GCD (HCF) and LCM
  • View step-by-step calculations (Advanced mode)
  • Understand results using prime factor visuals (Quick mode)
Methods used
  • Euclidean Algorithm (fast and reliable)
  • Prime Factorization (educational visuals)
  • LCM identity: LCM(a, b) = |a × b| ÷ GCD(a, b)

Learn with Advanced mode

Advanced mode is designed to help you understand the “why,” not just the final answer.

What you can see
  • Euclidean algorithm steps (for GCD)
  • LCM steps derived using GCD
  • Prime factor breakdown and chips
  • Visual separation of common vs max prime powers
Who it’s for

Students, teachers, and anyone preparing for exams or interviews who wants clear reasoning and repeatable steps.

Visual explanation of GCD and LCM

To make the concepts easier to grasp, this page shows prime-factor “chips” for each number (when factorization is feasible), and highlights the exact prime powers that form the final answer.

GCD (common factors)

Highlights show common prime powers (minimum exponent across all non-zero inputs).

2^23
LCM (combined factors)

Highlights show max prime powers (maximum exponent across inputs). If any input is 0, the LCM is 0.

2^33^2
Note: prime-factor visuals are automatically skipped for very large inputs to keep the page fast.

Common mistakes

  • Assuming LCM is always a × b (only true when the numbers are coprime)
  • Forgetting to simplify fractions using the GCD
  • Confusing when to use GCD vs LCM
  • Ignoring special cases like 0 or negative numbers (this calculator handles them correctly)

Examples to try

Example
GCD(20, 30) = 10
Example
LCM(8, 12) = 24
Example
GCD(3, 4, 6) = 1
Example
LCM(3, 4, 6) = 12

Tip: paste any of these into the input box above.

Related calculators

Frequently asked questions

Is GCD the same as HCF?
Yes. GCD (Greatest Common Divisor) and HCF (Highest Common Factor) mean the same thing.
Can GCD be negative?
No. By definition, GCD is always a non-negative number.
What is the LCM of 0 and a number?
The LCM of 0 and any number is 0 (the calculator uses this common convention).
Can I calculate GCD and LCM for more than two numbers?
Yes. This calculator supports 2–10 numbers.
Which method is best for GCD?
The Euclidean algorithm is the fastest and most reliable method for computing GCD.

Ready to calculate?

Enter your numbers above to get GCD & LCM instantly — or switch to Advanced mode to learn step by step.

Back to top