Skip to main content
L
Loopaloo
Buy Us a Coffee
All ToolsImage ProcessingAudio ProcessingVideo ProcessingDocument & TextPDF ToolsCSV & Data AnalysisConverters & EncodersWeb ToolsMath & ScienceGames
Guides & BlogAboutContact
Buy Us a Coffee
L
Loopaloo

Free online tools for developers, designers, and content creators. Your files are processed in your browser and are never uploaded - no accounts required. A few network utilities (like What's My IP and Currency Converter) call public APIs to do their job and say so on their pages.

support@loopaloo.com

Tool Categories

  • Image Tools
  • Audio Tools
  • Video Tools
  • Document & Text
  • PDF Tools
  • CSV & Data
  • Converters
  • Web Tools
  • Math & Science
  • Games

Company

  • About Us
  • Contact
  • Blog
  • FAQ

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer

Support

Buy Us a Coffee

© 2026 Loopaloo. All rights reserved. Built with privacy in mind.

Privacy|Terms|Disclaimer
  1. Home
  2. Math & Science
  3. GCD & LCM Calculator
Add to favorites

GCD & LCM Calculator

Find the GCD and LCM of two or more whole numbers of any size, with the Euclidean algorithm, prime factorisations, Bezout coefficients and common divisors shown.

Calculated locally in your browserMore math & scienceJump to full guide

Initializing in your browser…

You might also like

Prime Number Checker

Check whether any whole number is prime, and see its prime factors, divisors, nearby primes and Goldbach pairs, or list every prime in a range.

Scientific Calculator

A scientific calculator with exact fractions and decimals, degrees or radians, 34 functions and a desk-calculator mode. Rounded answers are labelled as rounded.

Graphing Calculator

Plot up to eight functions of x, find their roots, turning points and intersections, shade integrals and draw derivatives. Pan, zoom and share any graph.

A worked calculation

Two buses leave the same stop, one every 12 minutes and one every 18 minutes. You want to know how often they leave together, with the working.

Numbers

12
18
What GCD & LCM Calculator produces

Result

GCD: 6
LCM: 36
18 = 1 x 12 + 6
12 = 2 x 6 + 0
12 = 2^2 x 3, 18 = 2 x 3^2
Check: 6 x 36 = 216 = 18 x 12

The buses leave together every 36 minutes, the lowest common multiple of 12 and 18. The Euclidean algorithm finds the GCD first: 18 divided by 12 leaves 6, and 12 divided by 6 leaves nothing, so the GCD is 6. The LCM then follows as 12 / 6 x 18 = 36. The factorisations give the same answers another way: the shared primes at their lowest powers, 2 x 3, make 6, and every prime at its highest power, 2^2 x 3^2, makes 36. Multiplying the GCD by the LCM gives 216, which is exactly 12 x 18, as it must be for any two numbers.

Common divisors and multiples, with the working

Find the greatest common divisor (GCD) and the lowest common multiple (LCM) of two or more whole numbers, however many digits they have. The page writes out the Euclidean algorithm, the prime factorisation of every number, the Bezout coefficients and the full list of common divisors, and checks its own answer.

How it works

Two answers, any size. Type whole numbers into the boxes, one per box, and add as many boxes as you need. The GCD is the largest number that divides all of them exactly, and the LCM is the smallest positive number that all of them divide into. Both are worked out with exact whole-number arithmetic, so a twenty-digit input is as precise as a two-digit one and every digit of the answer is shown. That matters more than it sounds: the LCM of 123,456,789 and 987,654,321 is 13,548,070,123,626,141, and a calculator that multiplies the two numbers in ordinary floating point before dividing by the GCD comes out one short. You can paste a list such as 12, 18, 24 to fill several boxes at once, and thousands separators such as 1,000,000 are read as part of the number.

The working, written out. For two numbers the Euclidean algorithm is shown line by line in the form a = q x b + r, starting with the larger number and ending at the line where the remainder reaches zero; the divisor in that line is the GCD. For a longer list the page shows how the answer is built two numbers at a time, such as gcd(6, 10) = 2 and then gcd(2, 15) = 1. The prime factorisation of every number gives a second route to the same answers: the GCD takes the lowest power of each prime the numbers share, and the LCM takes the highest power of each prime in any of them. Large numbers with no small factors are factorised in the background, so the page stays responsive, and a Stop button appears while that work is running.

Bezout coefficients and common divisors. For two numbers the page also gives whole numbers x and y with ax + by = gcd(a, b). They come from the extended Euclidean algorithm and are what you need to find a modular inverse or to solve a linear equation in whole numbers. The common divisors are listed in full, and they are exactly the divisors of the GCD.

Checked, and clear about edge cases. For two numbers, GCD x LCM always equals the product of the numbers, and the page works out both sides and shows that they agree. Zero is handled by definition: gcd(0, n) is n, because every number divides zero, and lcm(0, n) is 0. Negative numbers are accepted and give the same positive GCD and LCM as their sizes. When a list of three or more has a GCD of 1, the page also says whether some pair still shares a factor, as 6, 10 and 15 do. A decimal, a number in exponent notation or a box holding two numbers is pointed out, and no answer is shown until it is fixed.

Examples

  • 12 and 18

    GCD 6 and LCM 36. The algorithm takes two lines: 18 = 1 x 12 + 6, then 12 = 2 x 6 + 0.

  • 270 and 192

    GCD 6 and LCM 8,640, reached in four steps: 270 = 1 x 192 + 78, 192 = 2 x 78 + 36, 78 = 2 x 36 + 6 and 36 = 6 x 6 + 0.

  • 6, 10 and 15

    GCD 1 and LCM 30. No number above 1 divides all three, yet every pair shares a factor: 6 and 10 share 2.

  • Two nine-digit numbers

    123,456,789 and 987,654,321 have GCD 9 and LCM 13,548,070,123,626,141, with every digit exact.

How to use

  1. 1Type a whole number in each box. Use Add a number for a longer list, or paste a list to fill several boxes at once.
  2. 2Read the GCD and the LCM, each with its own copy button.
  3. 3Follow the Euclidean algorithm, or the step-by-step working for a longer list, to see how the answer was reached.
  4. 4Check the prime factorisations, the Bezout coefficients and the list of common divisors underneath.
  5. 5Press Share to send a link that opens the same numbers.

Key features

  • GCD and LCM of two or more whole numbers, exact at any size
  • Every digit of the answer shown, never rounded or in exponent notation
  • The Euclidean algorithm written out line by line
  • Step-by-step working for lists of three or more numbers
  • Prime factorisation of every number, the GCD and the LCM
  • Bezout coefficients x and y with ax + by = gcd(a, b)
  • The full list of common divisors
  • GCD x LCM checked against the product of the two numbers
  • Paste a list to fill several boxes, with thousands separators understood
  • Zero, negative numbers and coprime lists explained

Tips & best practices

  • To simplify a fraction in one go, enter its top and bottom and divide both by the GCD.
  • For three or more numbers the order does not matter: the GCD and LCM are the same however the list is arranged.
  • If the GCD of two numbers is 1, their LCM is their product.
  • Bezout coefficients give modular inverses: since 3 x (-2) + 7 x 1 = 1, the inverse of 3 modulo 7 is -2, which is 5.

When this is useful

  • Simplifying fractions

    Divide the top and bottom by their GCD: the GCD of 84 and 126 is 42, so 84/126 is 2/3.

  • Adding fractions

    The LCM of the denominators is the lowest common denominator: for 5/12 + 7/18 it is 36.

  • Schedules and cycles

    Two buses that leave every 12 and every 18 minutes leave together again every 36 minutes, their LCM.

  • Modular arithmetic

    When the GCD is 1, the Bezout coefficients give a modular inverse directly, a step used in number theory and cryptography.

  • Homework with working

    Every line of the Euclidean algorithm is written in the same form you would use on paper.

Frequently asked questions

How do I find the GCD of two numbers?

Divide the larger by the smaller and keep the remainder, then divide the smaller number by that remainder, and repeat until the remainder is 0. The last divisor is the GCD. For 18 and 12: 18 = 1 x 12 + 6, then 12 = 2 x 6 + 0, so the GCD is 6. This is the Euclidean algorithm, and the page writes it out for you.

How do I find the LCM?

Divide one number by the GCD and multiply by the other. For 12 and 18 the GCD is 6, so the LCM is 12 / 6 x 18 = 36. Dividing first keeps the numbers small, which is part of why the answer stays exact for very large inputs.

How large can the numbers be?

There is no fixed limit. The GCD, the LCM, the Euclidean algorithm and the Bezout coefficients are exact for numbers with hundreds of digits. Factorising a very large number with no small prime factors can take a while; it runs in the background, and if part of a number cannot be broken down in reasonable time the page says so.

What is the GCD of 0 and a number?

The number itself, ignoring its sign, because every number divides 0. The LCM of 0 and any number is 0, since 0 is the only multiple of 0. The GCD of 0 and 0 is taken to be 0.

What does coprime mean?

Two numbers are coprime when their only common divisor is 1, so their GCD is 1 and their LCM is their product, as with 8 and 15. For a longer list, a GCD of 1 does not make every pair coprime: 6, 10 and 15 have a GCD of 1, but 6 and 10 share 2.

What is Bezout's identity?

For any two whole numbers a and b there are whole numbers x and y with ax + by = gcd(a, b). For 12 and 18, 12 x (-1) + 18 x 1 = 6. The coefficients come from the extended Euclidean algorithm and are used to find modular inverses and to solve equations such as ax + by = c in whole numbers.

Can I use negative numbers?

Yes. The GCD and the LCM are given as positive numbers, the same as for the sizes of the numbers, and the factorisation of a negative number starts with -1.

Related tools and how they differ

  • Fraction Calculator: Use it to simplify and add fractions, which rely on the GCD and the LCM.
  • Prime Number Checker: Use it to test one number for primality and see all of its divisors.
  • Aspect Ratio Calculator: Use it to reduce a width and height to their simplest ratio, which divides both by their GCD.

Private by design

Every calculation runs locally in your browser. Your numbers and expressions are not transmitted or stored.