01What is GCD & LCM Calculator?
Type two or more whole numbers into the box, separated by commas or spaces, and the calculator gives you their greatest common divisor and least common multiple straight away. It also shows a prime factorization for each number, and when you enter exactly two numbers it writes out every step of the Euclidean algorithm. The GCD comes from the classic Euclidean algorithm, the one described in Euclid's Elements (Book VII). It repeatedly replaces the pair (a, b) with (b, a mod b) until the remainder hits zero. For a list, the tool folds that across every number. The LCM is built pairwise from the standard identity lcm(a, b) = |a| / gcd(a, b) × |b|. Dividing before multiplying keeps the intermediate values small. Everything runs on JavaScript BigInt, not regular floating point numbers. That matters more than you might think. LCMs grow fast, and ordinary JavaScript numbers lose precision past 2^53. With BigInt, the LCM of 2147483648 and 1162261467 comes out as exactly 2495937495082991616. Here is a small worked case. Enter 1071, 462 and the steps panel shows 1071 = 2 × 462 + 147, then 462 = 3 × 147 + 21, then 147 = 7 × 21 + 0. So the GCD is 21, and the LCM card reads 23562. The factorization list shows 1071 = 3^2 × 7 × 17 and 462 = 2 × 3 × 7 × 11. You can see the shared 3 × 7 right there. The input parser is strict on purpose. Only whole numbers count. Zero, decimals like 1.5 and any text get listed under an Ignored note, so nothing is quietly rounded behind your back. Negative values are accepted and treated by their absolute value, and their factorization starts with -1. If the GCD is 1, a green line tells you the numbers are coprime. There are honest limits too. Factorization uses plain trial division up to the square root, so any number above 10^12 skips it and shows a short "too large to factor here" message instead. The GCD and LCM still work for those. The Euclidean steps only appear for a pair, not for three or more numbers. You need at least two non-zero values before any result shows up. The math happens in your browser tab as you type. Your numbers are not uploaded to our server.
Programmers working out schedule overlaps or screen ratios, plus students and teachers checking fraction and number theory homework. The tool runs entirely in your browser, so your data never leaves your device.
02How to use GCD & LCM Calculator
- Type your values into the Numbers (comma-separated) box, for example 24, 36, 48. Spaces work as separators too.
- Read the GCD and LCM cards that appear once at least two non-zero whole numbers are present.
- Check the Prime Factorization panel to see which primes each number shares.
- Enter exactly two numbers if you want the Euclidean Algorithm panel with every division step.
- Click Copy to grab a summary of the numbers, GCD and LCM, or the reset button to clear the box.
03Worked examples
- Input:
12, 18 - Result:
GCD 6, LCM 36 18 = 1 × 12 + 6 12 = 2 × 6 + 0 GCD = 6 - The Euclidean steps always start from the larger number of the pair.
- Input:
1071, 462 - Result:
GCD 21, LCM 23562 1071 = 3^2 × 7 × 17 462 = 2 × 3 × 7 × 11 - Factorization lines shown. The shared 3 × 7 is the GCD.
- Input:
8, 9, 21 - Result:
GCD 1, LCM 504 These numbers are coprime (GCD = 1) - No Euclidean steps for three numbers. The LCM is 504, not 8 × 9 × 21 = 1512, because 9 and 21 share a 3.
- Input:
0, 9, 12, 1.5 - Result:
GCD 3, LCM 36 Ignored (not a non-zero whole number): 0, 1.5 - Zero and the decimal are left out and reported, not rounded.
- Input:
-4, 6 - Result:
GCD 2, LCM 12 -4 = -1 × 2^2 - Signs are dropped for the GCD and LCM, but the factorization keeps a -1.
- Input:
2147483648, 1162261467 - Result:
GCD 1, LCM 2495937495082991616 2147483648 = 2^31 1162261467 = 3^19 - The LCM is above 2^53 and stays exact thanks to BigInt. The 24 Euclidean steps are trimmed here.
04Common use cases
- Reducing a fraction like 84/126 to its simplest form by dividing top and bottom by the GCD.
- Finding when two cron jobs that run every 45 and 60 minutes will fire at the same minute again (the LCM, 180).
- Getting the simplest aspect ratio of a 1920 × 1080 screen by dividing both sides by their GCD of 120.
- Picking a common denominator before adding fractions such as 1/8 + 1/9 + 1/21 in homework.
- Checking that two gear tooth counts are coprime so wear spreads evenly across every tooth.
- Walking a class through the Euclidean algorithm with the steps printed line by line.
- Confirming an exact LCM for large IDs or periods where plain JavaScript numbers would round.
05Tips
- The GCD is the product of shared primes at their lowest powers. The LCM uses every prime at its highest power. Compare the factorization lines and you can check both by eye.
- In your own code, write a / gcd(a, b) * b instead of a * b / gcd(a, b). The product can overflow before the division brings it back down.
- Watch the Ignored note. A stray 0 or a value like 2.5 gets dropped from the calculation, which can change the answer you expected.
- Two consecutive integers are always coprime, so 14, 15 is a quick sanity check that should show GCD 1.
06Related concepts
greatest common divisor, least common multiple, Euclidean algorithm, prime factorization, coprime numbers.
Frequently Asked Questions
What is GCD & LCM Calculator?
GCD & LCM Calculator is a free, browser-based developer tool on AIDToolStack. Calculate GCD and LCM with steps It requires no installation or sign-up and works entirely in your browser.
Is GCD & LCM Calculator free to use?
Yes. No sign-up, no fees and no usage cap.
Does GCD & LCM Calculator store my data?
No. It runs in your browser; nothing is uploaded.