Number & Math

GCD / LCM Calculator

Greatest common divisor, least common multiple, prime check and factorisation.

Numbers (comma- or space-separated)

3 valid number(s).

GCD

6

LCM

72

About this tool

Type two or more integers and see their GCD (greatest common divisor), LCM (least common multiple) and the prime factorisation of each. Single-number mode runs a primality test and lists all factors. Handles arbitrary precision via BigInt, so 50-digit numbers work.

FAQs

What's the difference between GCD and LCM?

GCD is the largest number that divides every input - useful for reducing fractions. LCM is the smallest number divisible by every input - useful for synchronising periodic events or adding fractions.

How big can the inputs be?

Practically unlimited - the tool uses BigInt. Very large numbers slow primality testing into the seconds range; factoring a 50-digit semiprime can take much longer (that's RSA territory).

Which primality test is used?

Miller-Rabin with deterministic witnesses for numbers up to 3 * 10^18, falling back to probabilistic Miller-Rabin (20 rounds) for larger inputs. False-positive probability under 1 / 4^20.

How does factorisation work?

Trial division by small primes first, then Pollard-Rho for larger composite factors. Numbers with very large prime factors (50+ digits) can stall - those are the cases RSA was designed around.

Why is GCD(0, n) = n?

By definition, the GCD of 0 and n is n - every number divides 0. The Euclidean algorithm relies on this base case to terminate.

Other tools