CodeKitHub
English
Everyday Tools

GCD and LCM Calculator

Enter two or more whole numbers and get the greatest common divisor (GCD, also called HCF) and the least common multiple (LCM) instantly, with the Euclidean algorithm steps shown so you can see exactly how the answer was reached. Useful for simplifying fractions, splitting things into equal groups, or lining up repeating schedules.

Everything is calculated in your browser.

What Is This Tool?

The greatest common divisor (GCD) of a set of numbers is the largest number that divides all of them with no remainder. The least common multiple (LCM) is the smallest number that all of them divide into evenly. This tool computes both using the Euclidean algorithm, which repeatedly replaces the larger number with the remainder of dividing it by the smaller one until the remainder reaches zero — the last nonzero remainder is the GCD.

Once the GCD is known, the LCM follows directly from the relationship LCM(a, b) = (a × b) ÷ GCD(a, b), extended pairwise for three or more numbers. Both values are fundamental in simplifying fractions, working with ratios, and solving scheduling problems where events repeat on different cycles.

Why Use It?

  • Calculates GCD and LCM together for two or more integers in one step.
  • Shows the Euclidean algorithm's working, not just the final answer.
  • Handles any number of inputs, not just pairs.
  • Instant results as you type — no page reload.
  • Free and private — everything runs in your browser.

How to Use

  1. Enter two or more whole numbers, separated by commas or in separate fields.
  2. The calculator applies the Euclidean algorithm automatically.
  3. Read the GCD and LCM results.
  4. Expand the steps to see exactly how each division and remainder led to the answer.

Example

Input

48 and 18

Output

GCD = 6, LCM = 144

Euclidean algorithm: 48 = 2×18 + 12, 18 = 1×12 + 6, 12 = 2×6 + 0 — the last nonzero remainder, 6, is the GCD. LCM = (48×18)/6 = 144.

GCD vs LCM at a glance

GCDLCM
Full nameGreatest Common DivisorLeast Common Multiple
What it findsLargest shared factorSmallest shared multiple
Result vs inputsAlways ≤ the smallest inputAlways ≥ the largest input
Typical useSimplifying fractionsCommon denominators, repeating schedules

Related tools

For other everyday and math calculations that pair well with GCD and LCM, try these tools.

Percentage Calculator · Rule of Three Calculator · Unit Converter

Frequently Asked Questions

What is the difference between GCD and LCM?

The GCD (greatest common divisor, also called HCF or highest common factor) is the largest number that divides two or more numbers exactly. The LCM (least common multiple) is the smallest number that those numbers all divide into exactly. GCD shrinks toward a shared factor; LCM grows toward a shared multiple.

How do you calculate GCD by hand with the Euclidean algorithm?

Divide the larger number by the smaller one and note the remainder. Replace the larger number with the smaller number, and the smaller number with the remainder. Repeat until the remainder is zero — the last nonzero remainder is the GCD. For example, for 48 and 18: 48 ÷ 18 leaves remainder 12; 18 ÷ 12 leaves remainder 6; 12 ÷ 6 leaves remainder 0, so the GCD is 6.

How is LCM calculated from GCD?

For two numbers, LCM(a, b) = (a × b) ÷ GCD(a, b). For 48 and 18, that's (48 × 18) ÷ 6 = 144. For three or more numbers, apply the same formula pairwise: find the LCM of the first two, then find the LCM of that result with the next number, and so on.

Where does GCD/LCM show up in everyday life?

GCD simplifies fractions to their lowest terms (dividing numerator and denominator by their GCD) and helps split items into the largest possible equal groups. LCM is what you need when lining up repeating cycles — for example, figuring out when two events with different repeat intervals will next fall on the same day, or finding a common denominator when adding fractions.

Can this calculator handle more than two numbers?

Yes. Enter as many whole numbers as you need; the tool finds the GCD and LCM shared across all of them by applying the pairwise algorithm sequentially.

Is my data stored anywhere?

No. The calculation runs entirely in your browser with JavaScript; nothing you enter is sent to a server, stored or logged.

Related Tools