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. All processing happens entirely in your browser - your files never leave your device. No uploads, no accounts, complete privacy.

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

Calculate Greatest Common Divisor and Least Common Multiple of multiple numbers. Shows prime factorization and common divisors.

Find the greatest common divisor (GCD) and least common multiple (LCM) of two or more integers. Add as many numbers as you like; results appear instantly along with the prime factorization of each input and the common divisors they share.

Calculated locally in your browserMore math & scienceJump to full guide

Initializing in your browser…

You might also like

Prime Number Checker

Check if a number is prime and find prime factorization

Scientific Calculator

Advanced calculator with scientific functions and history

Graphing Calculator

Plot and visualize mathematical functions with multiple overlays

A worked calculation

You need the greatest common divisor and least common multiple of 48 and 180 for a fraction-reduction step.

Numbers

48 and 180
GCD & LCM Calculator produces

Result

GCD = 12   LCM = 720
(48 = 2⁴·3,  180 = 2²·3²·5)

From the prime factorisations, GCD takes the lowest shared powers (2²·3 = 12) and LCM the highest (2⁴·3²·5 = 720), and indeed GCD × LCM = 48 × 180. Showing the factorisation makes the relationship between the two results clear instead of magical.

What this calculator does

Find the greatest common divisor (GCD) and least common multiple (LCM) of two or more integers. Add as many numbers as you like; results appear instantly along with the prime factorization of each input and the common divisors they share.

How it works

The calculator works on a list of integers - two input fields by default, with an Add button to append more and a trash icon to remove any once you have more than two. Each field is sanitized as you type so only digits and a single leading minus survive, and the result engine runs parseInt over the list and silently drops any entry that is NaN or zero, so you need at least two valid non-zero integers before anything is computed. The GCD is found with the classic Euclidean algorithm (a repeated `a mod b` loop until the remainder is zero), and because every value is passed through Math.abs first, negative inputs like -12 are treated by magnitude. For three or more numbers, both the GCD and LCM are reduced pairwise with a left fold - gcd(a, b, c) is computed as gcd(gcd(a, b), c) - rather than by any single multi-argument formula.

The LCM is derived from the identity lcm(a, b) = |a x b| / gcd(a, b) rather than by listing multiples, which keeps it exact for the pairwise fold. Because that product can grow quickly, the LCM panel switches to JavaScript exponential notation with four decimals (toExponential(4)) whenever the value exceeds 999,999,999,999, while smaller results use grouped thousands separators. Alongside the two headline numbers, the tool prints a prime factorization for each input using trial division up to the square root, formatted with caret exponents - so 12 renders as 2^2 x 3 and 18 as 2 x 3^2 - and a chip list of every common divisor, which it computes as the divisors of the GCD (the divisors of the GCD are exactly the divisors shared by all inputs).

When you enter exactly two numbers, an extra Verification panel demonstrates the GCD x LCM = |a x b| relationship explicitly: it shows GCD x LCM, evaluates that product, shows |a| x |b| beside it, and prints a green check mark when the two match. This panel only appears in the two-number case - it is not shown for three or more inputs, since the simple product identity does not generalize. Note that despite what older descriptions may suggest, the tool does not print an iterative step-by-step Euclidean trace; it shows the final GCD and LCM plus the factorization, common-divisor, and (for two numbers) verification panels. Every result recomputes instantly via a memoized hook as you edit fields, and both the GCD and LCM values have one-click copy buttons.

Examples

  • GCD/LCM of 48, 18, 24

    Add a third field and enter 48, 18, 24. The tool folds pairwise to GCD 6 and LCM 144, lists factorizations 48 = 2^4 x 3, 18 = 2 x 3^2, 24 = 2^3 x 3, and shows the common divisors of the GCD (1, 2, 3, 6). With three numbers no Verification panel appears.

  • Two-number verification: 12 and 18

    Enter 12 and 18 to get GCD 6 and LCM 36. The Verification panel shows 6 x 36 = 216 and |12| x |18| = 216 with a green check, demonstrating the GCD x LCM = |a x b| identity that only displays in the two-number case.

How to use

  1. 1Enter at least two non-zero integers, one per field (use Add to include more)
  2. 2View the GCD and LCM, computed pairwise with the Euclidean algorithm
  3. 3Review each number's prime factorization and the shared common divisors

Key features

  • GCD and LCM for two or more numbers at once (pairwise Euclidean algorithm)
  • Prime factorization of each input number
  • List of common divisors shared by all inputs
  • GCD x LCM = product verification for two numbers
  • One-click copy of the GCD and LCM results

Tips & best practices

  • Negative entries are fine - each value is run through Math.abs, so -12 and 12 give identical GCD/LCM results.
  • A zero or blank field is ignored rather than causing an error, so you can leave spare fields empty; you just need two valid non-zero integers for results to appear.
  • If the LCM panel suddenly shows something like 1.2346e+12, the true value simply exceeded 999,999,999,999 and switched to four-digit exponential notation.

Frequently asked questions

Can I enter more than two numbers?

Yes. The tool computes the GCD and LCM across any number of inputs by iterating pairwise. You need at least two non-zero integers.

What is the relationship between GCD and LCM?

For two numbers a and b: GCD(a, b) x LCM(a, b) = |a x b|. The tool shows this verification when exactly two numbers are entered.

Related tools and how they differ

  • Prime Number Checker: Classifies a single number as prime, lists its factors, twin or Sophie Germain status, Goldbach pairs, and nearby primes; use it to inspect one number.

Private by design

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