Free GCD and LCM Calculator
Enter two or more integers to calculate their greatest common divisor (GCD) and least common multiple (LCM). View the results and, where supported, follow the calculation steps to understand how they are obtained.
Free GCD and LCM Calculator
Accepts 2 to 100 positive integers, negative integers, or 0. Signs do not change GCD or LCM magnitude.
The Euclidean algorithm repeatedly applies division with remainder a = (q × b) + r until the remainder reaches 0. The last non-zero remainder is the GCD.
| Step | Euclidean Division Equation (a = q × b + r) | Remainder |
|---|---|---|
| 1 | 18 = (1 × 12) + 6 | 6 |
| 2 | 12 = (2 × 6) + 0 | 0 |
LCM(12, 18) = (|12 × 18|) ÷ GCD(12, 18)
= (12 ÷ 6) × 18 = 36
| Number | Prime Factor Exponent Representation |
|---|---|
| 12 | 2² × 3 |
| 18 | 2 × 3² |
1. Free GCD & LCM Calculator Overview & Capabilities
The ToolMono Free GCD & LCM Calculator is a mathematical engine engineered to compute the Greatest Common Divisor (GCD)—also known as the Greatest Common Factor (GCF) or Highest Common Factor (HCF)—and the Least Common Multiple (LCM) of two or more integers.
Operating completely within your browser memory using native ECMAScript BigInt arithmetic, the calculator eliminates floating-point rounding errors (Number.MAX_SAFE_INTEGER = 9,007,199,254,740,991). It supports multi-number sets (from 2 up to 100 integers) with values up to 1,000 digits, delivering exact step-by-step Euclidean division equations, prime factorization matrices, and simplified ratios.
Accepts integers up to 1,000 digits without silent truncation, rounding, or JavaScript floating-point precision loss.
Every modulo reduction and factorization runs locally in your browser sandbox. Numbers and problem sets are never uploaded or tracked.
Generates explicit Euclidean algorithm division steps a = (q × b) + r, multi-number iterative steps, and prime factorization matrices.
2. How to Use the Online GCD & LCM Calculator
Follow this simple guide to calculate greatest common divisors and least common multiples:
- Enter Integers: Type two or more integers into the input box separated by commas, spaces, or newlines (e.g.
12, 18or24, 36, 60). You can also click any of the 6 worked presets to load sample scenarios. - Select Calculation View: Choose between Euclidean Algorithm (standard division steps), Prime Factor Matrix (exponential prime breakdown), Listing Factors, or Listing Multiples.
- Inspect Outputs: View the live GCD, LCM, coprime indicator, and simplified ratio (for two numbers).
- Review Mathematical Proofs: Inspect the Euclidean division table (
a = (q × b) + r) and the LCM derivation formula ((|a| ÷ GCD) × |b|). - Copy Results: Use the one-click copy buttons to copy the GCD, LCM, both results together, or the formatted step-by-step proof to your clipboard.
3. What Is GCD? What Is LCM? (Definitions & Regional Terms)
Greatest Common Divisor (GCD / GCF / HCF)
The Greatest Common Divisor (GCD) of two or more non-zero integers is the largest positive integer that divides each of the numbers without leaving a remainder.
- GCF (Greatest Common Factor): Term commonly taught in United States and Canadian elementary mathematics.
- HCF (Highest Common Factor): Standard educational term in the United Kingdom, India, and Commonwealth nations.
- GCD: The universal scientific, algorithmic, and university standard.
Least Common Multiple (LCM)
The Least Common Multiple (LCM)—sometimes called Lowest Common Multiple—of two or more non-zero integers is the smallest positive integer that is divisible by all numbers in the set.
Multiples of 12: 12, 24, 36, 48, 60, 72, 84, 96, 108...
Multiples of 18: 18, 36, 54, 72, 90, 108, 126...
Common Multiples: 36, 72, 108... Smallest positive multiple is 36.
4. How the Euclidean Algorithm Calculates GCD with Modulo Steps
Discovered around 300 BC by Euclid of Alexandria, the Euclidean Algorithm is one of the oldest and most elegant numerical algorithms in history.
Mathematical Principle:
The greatest common divisor of two integers a and b also divides their remainder:
At each step, we express a in terms of quotient q and remainder r:
We then replace a with b, and b with r, continuing until the remainder reaches 0. The final non-zero remainder is the GCD.
Because the remainder has reached 0, the last non-zero remainder is 6. Therefore, GCD(48, 18) = 6.
5. How LCM Is Derived from the GCD (Preventing Overflow)
For any two integers a and b, their product equals the product of their GCD and LCM:
Rearranging this fundamental theorem gives the standard formula to compute the LCM:
In computer programming and fixed-width integer arithmetic, computing (a * b) / gcd can trigger 64-bit integer overflow if the product a * b exceeds numeric limits.
ToolMono implements the mathematically equivalent form:
Because GCD(a, b) divides a evenly, performing the division first drastically reduces the intermediate number, guaranteeing exact precision without overflow.
6. GCD vs. LCM Comparison Table
| Property | Greatest Common Divisor (GCD) | Least Common Multiple (LCM) |
|---|---|---|
| Mathematical Role | Largest common factor dividing all inputs | Smallest positive number divisible by all inputs |
| Magnitude Bound | GCD ≤ min(|a|, |b|) | LCM ≥ max(|a|, |b|) |
| Example (12, 18) | 6 | 36 |
| Coprime Case (8, 15) | 1 | 8 × 15 = 120 |
| Zero Case (a, 0) | |a| (nonzero a) | 0 |
| Primary Application | Simplifying fractions, Euclidean geometry | Adding fractions (common denominator), repeating cycles |
7. Finding GCD and LCM for Three or More Numbers (Iterative Folding)
A frequent mathematical mistake is assuming the product identity holds for three numbers (GCD × LCM = a × b × c). This identity is strictly false for three or more numbers!
The Associative Pairwise Folding Rule:
Both GCD and LCM satisfy the associative property over integers. To calculate the GCD and LCM of a set [a, b, c, d], we fold the operations pairwise:
- Step 1: Compute GCD(24, 36) = 12, and LCM(24, 36) = (24 ÷ 12) × 36 = 72.
- Step 2: Compute GCD(12, 60) = 12, and LCM(72, 60): GCD(72, 60) = 12 → (72 ÷ 12) × 60 = 360.
8. Prime Factorization & Exponent Matrix Method
GCD and LCM can also be derived directly from the prime factorizations of each number:
- GCD: Take the minimum exponent of each common prime factor across all numbers:
GCD = ∏ p^min(e_i). - LCM: Take the maximum exponent of every prime factor present in any number:
LCM = ∏ p^max(e_i).
9. Real-World Applications: Simplifying Fractions & Periodic Events
To reduce any fraction a / b to its simplest irreducible form, divide both the numerator and the denominator by their GCD:
To add or subtract fractions with unlike denominators, the Lowest Common Denominator (LCD) is exactly the LCM of their denominators:
10. Mathematical Edge Cases: Zero, Negative Integers & Coprime Pairs
Divisors and multiples are conventionally considered positive magnitudes in number theory. Therefore, GCD(-12, 18) = GCD(12, 18) = 6, and LCM(-12, 18) = 36. Negative signs do not alter GCD or LCM magnitudes.
Because every non-zero integer divides 0 (0 ÷ k = 0), GCD(a, 0) = |a|. However, GCD(0, 0) is conventionally defined as 0 in discrete mathematics and computational software libraries. LCM(a, 0) = 0.
Two numbers are coprime if GCD(a, b) = 1 (e.g. 8 and 15, or 17 and 31). They share no common factor other than 1. When numbers are coprime, their LCM strictly equals their product: LCM(a, b) = |a × b|.
If all input numbers are identical, their GCD is simply |a|, and their LCM is also |a| (e.g. GCD(25, 25) = 25 and LCM(25, 25) = 25).
11. Frequently Asked Questions (9 Core FAQs)
12. Authoritative Standards & Mathematical References
Consult official standards repositories, digital libraries of mathematical functions, and number theory specifications:
NIST Digital Library of Mathematical Functions: Number Theory
NIST reference for Euclidean algorithm and greatest common divisor.
ISO 80000-2: Quantities and Units — Mathematics
ISO standard for integer number theory and coprimality.
ECMAScript BigInt & Integer Arithmetic
JavaScript language specification for exact integer operations.
Related Tools
Browse all toolsPrime Checker
Enter a whole number to check whether it is prime or composite. Get a clear result, inspect the available factorization details, and understand how primality testing works.
Online Calculator
Free online calculator for quick everyday math, complex expressions, parentheses, percentages, and powers. Includes keyboard input and local calculation history.
Scientific Calculator
Use ToolMono's free Scientific Calculator for advanced mathematical calculations. Supports trigonometric, inverse, hyperbolic, logarithmic, exponential, factorial, scientific notation, degree/radian modes, calculation history, and 100% client-side processing.
Binary to Decimal Converter
Free online binary to decimal and decimal to binary converter. Supports BigInt arbitrary precision, signed two's complement, bit width validation, and step-by-step breakdowns.
Decimal ↔ Hex Converter
Free online Decimal to Hex Converter. Convert base-10 to base-16 hexadecimal instantly. Supports BigInt, two's complement, 8–64 bit signed/unsigned, and live steps.
Decimal to Octal Converter
Free online Decimal to Octal converter with instant step-by-step division steps. Convert Base-10 to Base-8 and Octal to Decimal accurately in your browser.