Home GCD and LCM
GCD and LCM
12 and 18 have GCD 6 and LCM 36. 12, 18, and 24 have 6 and 72. The LCM of 1,000,000,000 and 999,999,999 does not fit in a safe integer, so it stops.
Why this exists
The Euclidean algorithm divides until the remainder is 0. 18=12×1+6 and 12=6×2+0, so the last divisor is the greatest common divisor.
The product of two numbers divided by their greatest common divisor is the least common multiple. Three numbers repeat that step in pairs.
-
01How to use it
Typing 12, 18 shows GCD 6 and LCM 36.
Spaces work too, as in 12 18 24. A semicolon also splits numbers.
Copy puts both lines on the clipboard. Clearing the field hides the result.
-
02What you get
12, 18 have GCD 6 and LCM 36.
12, 18, 24 have 6 and 72. 7, 13 have 1 and 91.
0, 5 have 5 and 0. -12, 18 have 6 and 36.
Entered12, 18
12, 18 6 and 36 12, 18, 24 6 and 72 0, 5 5 and 0 -12, 18 6 and 36 -
03Worth knowing
A single number stops. A decimal such as 1.5 also stops.
1,000,000,000 and 999,999,999 differ by 1, so the divisor is 1, but the multiple is too large and the page stops.
More than 20 numbers stops. 1,000,000,001 also stops.
Closing the tab clears the numbers. Nothing is sent to a server.
Questions
- QWhat are 12 and 18?
- AThe GCD is 6 and the LCM is 36.
- QWhat about 12, 18, 24?
- AThe GCD is 6 and the LCM is 72.
- QWhat if a number is 0?
- A0 and 5 have GCD 5 and LCM 0.
- QWhat about 1,000,000,000 and 999,999,999?
- AThe least common multiple does not fit in a safe integer, so it stops.
How this page works it out
This page finds a greatest common divisor with the Euclidean algorithm. The larger number is replaced by the remainder of dividing it by the smaller one, and a remainder of 0 makes the last divisor the greatest common divisor. 18=12×1+6 and 12=6×2+0, so 12 and 18 have divisor 6. The least common multiple divides one number by that divisor and multiplies by the other. 12÷6×18 is 36.
Three or more numbers continue from the front to the back. 12, 18, and 24 have divisor 6 and multiple 72. 7 and 13 have 1 and 91. 0 and 5 have 5 and 0, and 0 and 0 are both 0. -12 and 18 drop the sign and have 6 and 36. 1,000 is read as one thousand, and a comma alone also splits numbers, as in 12,18.
From 2 to 20 whole numbers are read, and each absolute value runs up to 1,000,000,000. A single number, a decimal such as 1.5, or 1,000,000,001 stops. 1,000,000,000 and 999,999,999 differ by 1, so the divisor is 1, but the multiple does not fit in a safe integer and the page stops. This screen is separate from the page that simplifies fractions, and the numbers stay in this browser.