gcd-lcm
A GCD and LCM calculator finds the greatest common divisor (largest integer that divides every input without remainder) and the least common multiple (smallest integer divisible by every input) for two or more integers, using the Euclidean algorithm for fast computation. The ZTools GCD/LCM Calculator handles 2 to 100 inputs, shows the step-by-step Euclidean reduction so students can verify each modulo step, displays the prime factorizations of all inputs, and applies the identity GCD(a,b) Γ LCM(a,b) = a Γ b for two-input cases.
Use casesβ
Reducing fractions to lowest termsβ
Simplify 84/120: GCD(84,120) = 12, so 84/120 = 7/10. The calculator shows the work and the simplified fraction.
Adding fractions with unlike denominatorsβ
To add 1/6 + 1/8, find LCM(6,8) = 24. Then 1/6 = 4/24 and 1/8 = 3/24; sum = 7/24. The calculator gives the LCM in one click.
Scheduling repeating eventsβ
Bus A comes every 12 minutes, Bus B every 15. They'll arrive together every LCM(12,15) = 60 minutes. Useful for cron schedules and recurring meetings.
Number theory and abstract algebraβ
Bezout coefficients, Diophantine equations, modular arithmetic β all rely on GCD. The extended Euclidean output supports these tasks.
How it worksβ
- Enter two or more integers β Comma-separated. Negative inputs are allowed (their absolute value is used). Zero is allowed but special-cased: GCD(0, n) = n; LCM with 0 is 0.
- Euclidean algorithm runs for GCD β GCD(a, b) = GCD(b, a mod b), recursing until b = 0. For more than two inputs, GCD is computed iteratively: GCD(a,b,c) = GCD(GCD(a,b), c).
- LCM derived from GCD β LCM(a, b) = |a Γ b| Γ· GCD(a, b). Iterative for more inputs: LCM(a,b,c) = LCM(LCM(a,b), c).
- Read the result and the work β GCD, LCM, prime factorizations, and the step-by-step Euclidean reduction. All copyable.
Examplesβ
Input: GCD(48, 60)
Output: 12
Input: LCM(12, 15, 20)
Output: 60
Input: GCD(84, 120)
Output: 12, prime factorization: 84 = 2Β² Γ 3 Γ 7, 120 = 2Β³ Γ 3 Γ 5; common = 2Β² Γ 3 = 12.
Frequently asked questionsβ
How is the Euclidean algorithm different from prime factorization?
Both find the GCD. Prime factorization: factor each number and multiply common primes. Euclidean: repeatedly take remainders until zero. Euclidean is dramatically faster for large numbers β it's O(log min(a,b)) vs factorization which can be exponential.
What's the relationship between GCD and LCM?
For two positive integers: GCD(a,b) Γ LCM(a,b) = a Γ b. So if you know one, you can compute the other. Doesn't generalize to three or more numbers.
Why is GCD(0, n) defined as n?
Because n divides both 0 and n, and no larger integer divides n. The Euclidean algorithm terminates here: GCD(n, 0) = n is the base case.
How do I find GCD by hand for big numbers?
Repeated subtraction or modulo: GCD(a,b) = GCD(b, a mod b). Example: GCD(252, 105) = GCD(105, 42) = GCD(42, 21) = GCD(21, 0) = 21. Each step is fast.
When is the GCD 1?
When the numbers are coprime β share no common factor other than 1. Example: GCD(8, 9) = 1. Coprimality is important in cryptography (RSA modular arithmetic).
Tipsβ
- GCD distributes over multiplication: GCD(ka, kb) = k Γ GCD(a, b). Useful for simplifying complex expressions.
- For three or more numbers, computing pairwise then combining is the standard approach.
- Coprime β GCD = 1 β LCM = a Γ b. Three different ways to say the same thing.
- The extended Euclidean algorithm also returns Bezout coefficients (x, y such that ax + by = GCD), used in modular inverses.
Try it nowβ
The full gcd-lcm runs in your browser at https://ztools.zaions.com/gcd-lcm β no signup, no upload, no data leaves your device.
Last updated: 2026-05-05 Β· Author: Ahsan Mahmood Β· Edit this page on GitHub