# GCD & LCM calculator

Canonical HTML: https://easycalculatorsonline.com/math/gcd-lcm/

Find the greatest common divisor and least common multiple.

Interactive calculations run in your browser. Values below are the published example, not a calculation for your circumstances.

## Calculator inputs

| Input | Example value | Constraints and options |
| --- | --- | --- |
| First integer | 12 | min: 0. max: 1000000000. step: 1 |
| Second integer | 18 | min: 0. max: 1000000000. step: 1 |

**International formulas and units**

Use the units and assumptions stated on this page. Mathematical definitions apply across countries; material, device and measurement conditions remain your inputs.

## Published example result

> GCD & LCM
> Greatest common divisor: 6
> Least common multiple: 36
> Nonnegative integers. GCD(0,0) is reported as 0; LCM is 0 when either input is 0.
> https://easycalculatorsonline.com/math/gcd-lcm/

03 · UNDERSTAND THE METHOD

## How the gcd & lcm calculator works

The greatest common divisor, or GCD, is the largest positive integer that divides both input integers without a remainder. The least common multiple, or LCM, is the smallest positive multiple shared by two nonzero integer magnitudes. This calculator provides both results because they answer related but different questions. GCD helps reduce fractions or group objects evenly; LCM helps align repeating cycles or find a common denominator.

### The formula and its variables

g = gcd(|a|, |b|); lcm(a,b) = |(a/g) × b| for nonzero inputs

- **a, b**: Integer inputs.
- **g**: Greatest common divisor of the input magnitudes.
- **LCM**: Least common multiple, conventionally zero when one input is zero.

### The calculation, step by step

1. Enter two whole-number integers within the accepted range. The calculation uses absolute magnitudes when finding positive factors and multiples.
2. Use Euclid’s algorithm: replace a pair with the second number and the remainder until the remainder is zero. The last nonzero value is the GCD.
3. Divide one input by the GCD before multiplying by the other to obtain the LCM. Handle a zero input separately rather than dividing by zero.

### A worked example

For 12 and 18, common divisors are 1, 2, 3, and 6, so GCD is 6. The LCM is (12 ÷ 6) × 18 = 36. Two cycles lasting 12 and 18 time units align every 36 units when they start together. A fraction 12/18 reduces by the GCD to 2/3.

**Example inputs and calculated output**

| Input or output | Value |
| --- | --- |
| First integer | 12 |
| Second integer | 18 |
| Greatest common divisor | 6 |

### How to read the result and visual

The divisor describes the largest equal grouping possible for both numbers. The multiple describes the earliest shared repetition under integer cycles. When numbers have no shared factor besides one, the GCD is one and their LCM is the product of their magnitudes. Equal positive inputs produce the same value for both results.

### Assumptions, rounding, and limitations

These operations use integers, not fractional measurement durations or arbitrary real numbers. Decimal inputs should be scaled deliberately into integers before use. Very large LCM products can exceed exact browser integer precision and are constrained by validation. A zero pair is handled by explicit conventions rather than by claiming a largest positive divisor of both zeros.

### Frequently asked questions

### Can I enter negative integers?

This tool accepts nonnegative integers. For a negative integer, enter its absolute magnitude to obtain the positive GCD and LCM.

### Why is LCM useful for fractions?

A common denominator must be a multiple of each denominator; the least common multiple provides the smallest positive choice.

### Reference sources

- [OpenStax: least common multiples ↗](https://openstax.org/books/prealgebra-2e/pages/2-5-prime-factorization-and-the-least-common-multiple)

[How we check calculations and what verification covers](https://easycalculatorsonline.com/methodology/)

## Related calculators

[**Number base converter ↗**

Convert signed integers between bases2 through36.](https://easycalculatorsonline.com/conversions/number-base/)[**Ratio simplifier ↗**

Reduce an integer ratio without changing its proportions.](https://easycalculatorsonline.com/math/ratio/)[**Fraction calculator ↗**

Add, subtract, multiply, or divide two fractions.](https://easycalculatorsonline.com/math/fraction/)

[← Explore all calculators](https://easycalculatorsonline.com/#browse)

## Publisher and access

Published by Wolfpack Labs. Free to use; no account or payment required.

[Email wolfpack.labs.in@gmail.com](mailto:wolfpack.labs.in@gmail.com)

[About](https://easycalculatorsonline.com/about/) · [Methodology](https://easycalculatorsonline.com/methodology/) · [Contact](https://easycalculatorsonline.com/contact/) · [Privacy](https://easycalculatorsonline.com/privacy/) · [Terms](https://easycalculatorsonline.com/terms/)
