The identity with two numbers: 12 and 18
- Input
- 12, 18
- Expected output
- MDC = 6, MMC = 36, 6 × 36 = 216 = 12 × 18
This cross-check (GCD × LCM = product) is the fastest way to verify a two-number GCD is correct, without redoing the factorization.
gcd, lcm and prime factorization
GCD and LCM answer opposite questions about the same numbers: the largest divisor that fits into all of them, and the smallest multiple that all of them fit into. This page shows both calculations with prime factorization and the identity that ties GCD to LCM when there are exactly two numbers.
This cross-check (GCD × LCM = product) is the fastest way to verify a two-number GCD is correct, without redoing the factorization.
The GCD does not change from the (12,18) pair because 30 is also a multiple of 6; the LCM jumps from 36 to 180 because 30 brings in the prime factor 5, which was not present in either 12 or 18.
The GCD uses the lowest shared exponent of each prime (2¹ and 3¹, since 5 does not appear in all three), and the LCM uses the highest exponent of each prime present in any of the numbers (2², 3² and 5¹).
GCD (Greatest Common Divisor) is the largest positive integer that divides all numbers in the set without a remainder. It can be found with the Euclidean algorithm or by comparing prime factorizations and taking the lowest power of each shared prime. For example, GCD(12, 18) = 6.
If two numbers share no prime factor at all (they are coprime), the GCD is always 1 and the LCM is always the product of the two; it is the extreme case of the GCD×LCM=a×b identity, since GCD=1 forces LCM=a×b.
Because multiplying would count repeated prime factors more than once; the correct calculation reduces pairwise in sequence (LCM(LCM(a,b),c)), reusing the previous result instead of starting over, which also avoids overflow in intermediate steps.
Up to 10 positive integers per calculation, each up to 10^30; that ceiling exists because factorization by successive division becomes impractically slow well before that for numbers with no small factors.
No: the LCM is always greater than or equal to the largest number in the list, because by definition it must be a multiple of all of them, including the largest; LCM(12,18,30)=180 is larger than 30 for exactly that reason, though it can coincide with the largest number when that number is already a multiple of the others.
Numbers
All values stay in your browser. No data is sent to any server.