1. Home
  2. Calculators
  3. GCD and LCM Calculator

GCD and LCM Calculator

For fractions, ratios and number-theory problems: exact big-integer arithmetic with the working shown for two numbers.

Free, no sign-up. Runs in your browser: nothing is uploaded.

Free workspace included. Docs, spreadsheets, notes and tasks that save on your device. No sign-up.Take a look

How to use GCD and LCM Calculator

  1. Enter your numbers, or press a sample to see an example.
  2. Read the results and the table under them.
  3. Copy the results or download the table as a CSV file.

Features

  • GCD and LCM of up to 20 numbers of 30 digits
  • Prime factorization with exponents and divisor counts
  • Euclid’s algorithm steps for two numbers
  • Divisor list and perfect, abundant or deficient label
  • Handles large numbers with Miller-Rabin and Pollard’s rho

Supported formats

Input

  • Whole numbers separated by spaces, commas or lines

You get

  • On-screen results
  • Copyable text
  • CSV table

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the GCD and LCM Calculator is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Whole numbers up to 30 digits; factoring numbers above about 24 digits can fail if they are products of two large primes.
  • Everything runs in your browser; nothing you type is sent anywhere.

Guide

GCD, LCM and prime factorization of whole numbers

The greatest common divisor and the least common multiple are the working tools of fractions and ratios: the GCD simplifies a fraction and the LCM finds a common denominator. They are also the entry point to number theory through prime factorization. This calculator gives both for a list of whole numbers, with the prime factors, divisor counts and, for two numbers, every step of Euclid’s algorithm, using exact big-integer arithmetic so large inputs are not rounded.

How the GCD and LCM are found

The GCD comes from Euclid’s algorithm: divide the larger number by the smaller, replace the pair with the smaller number and the remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCD. The LCM of two numbers is a × b ÷ GCD, and for a list the tool combines the numbers one after another. A GCD of 1 means the numbers are coprime, which the page states when there are two or more numbers.

Using the tool

Enter whole numbers separated by spaces, commas or line breaks, from one to twenty, each with at most thirty digits. The page opens on 48, 180 and 360 and shows GCD 12, LCM 720 and a table of prime factorizations: 48 = 2⁴ × 3 with 10 divisors, 180 = 2² × 3² × 5 with 18, and 360 = 2³ × 3² × 5 with 24. The menu can limit the output to GCD and LCM only. Sample chips load four examples.

Euclid’s steps

With exactly two positive numbers the page prints the algorithm line by line. For 1071 and 462 it shows 1071 = 2 × 462 + 147, then 462 = 3 × 147 + 21, then 147 = 7 × 21 + 0, so the GCD is 21 and the LCM is 1071 × 462 ÷ 21 = 23,562. Three divisions suffice; the method never needs more than about five times the number of digits in the smaller number, which is why it is fast even for large inputs.

Factoring large numbers

Small primes are divided out first, then the Miller-Rabin test checks whether what remains is prime, and Pollard’s rho splits the rest. This handles typical numbers instantly: 600851475143, the number from a well-known programming puzzle, becomes 71 × 839 × 1471 × 6857, with 16 divisors. Numbers of 25 digits or more are not factored here, only tested for primality, and a product of two very large primes can still be out of reach.

Single numbers and divisors

If you enter one number below a trillion the tool also lists all its divisors, their sum and a classification. For 28 the divisors are 1, 2, 4, 7, 14 and 28; they add to 56, so the proper divisors sum to 28 and the number is perfect. 600851475143 has a divisor sum of 610,544,148,480, which is less than twice the number, so it is deficient. Long divisor lists are shortened to the first thirty.

Edge cases

Zero is divisible by every number, so the GCD ignores it and the LCM with zero is 0 by convention; the page says so. The number 1 has no prime factors, and a prime has itself as the only factor. Negative numbers, decimals and fractions are rejected with a message that names the offending item. Leading zeros are fine. Because the arithmetic is exact, a thirty-digit GCD is as reliable as a two-digit one.

Limits

The tool handles whole numbers only. It does not factor polynomials or work modulo a number, and it does not give the extended Euclidean coefficients. Factoring very large numbers is a hard problem in general, so a failure message is a limit of the browser, not a sign that the number is special. For fractions with several denominators, find the LCM of the denominators.

Checked against the current version of the GCD and LCM Calculator on .

Frequently asked questions

What is the quickest way to reduce a fraction with the GCD?

Divide the numerator and denominator by their GCD once. For 180/360 the GCD is 180, so the fraction is 1/2 in one step. Entering both numbers shows the GCD, and a result of 1 means the fraction is already in lowest terms. Repeated halving and checking primes takes longer.

Why is 28 called a perfect number?

Its proper divisors, 1, 2, 4, 7 and 14, add up to 28 itself. Entering a single number lists its divisors, their sum and a label: perfect when the proper divisors equal the number, abundant when they exceed it and deficient when they fall short. 28 is perfect, while 600851475143 is deficient.

How are very large numbers factored?

Small primes are divided out first, then Miller-Rabin tests primality and Pollard’s rho finds factors, which handles numbers of about 24 digits quickly.

What is the GCD of 0 and a number?

It is that number, because every number divides 0. The LCM with 0 is defined as 0.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.