Prime factorization
Every whole number greater than 1 can be written as a product of primes in exactly one way (fundamental theorem of arithmetic):
The division ladder finds it by dividing repeatedly by the smallest prime that still divides the number.
LCM and GCD from the factors
Write all numbers with the same primes (use exponent 0 where a prime is missing). Then
For two numbers the two are linked by
Worked example
Example
Find the LCM and GCD of 12, 18 and 30.
| ÷ | 12 | 18 | 30 |
|---|---|---|---|
| 2 | 12 | 18 | 30 |
| 2 | 6 | 9 | 15 |
| 3 | 3 | 9 | 15 |
| 3 | 1 | 3 | 5 |
| 5 | 1 | 1 | 5 |
| 1 | 1 | 1 |
\(12 = 2^2 \cdot 3\), \(18 = 2 \cdot 3^2\), \(30 = 2 \cdot 3 \cdot 5\).
LCM \(= 2^2 \cdot 3^2 \cdot 5 = 180\) (highest powers). GCD \(= 2^1 \cdot 3^1 = 6\) (powers common to all three; 5 is not in 12).
Euclid's algorithm
The GCD of two numbers can also be found without factoring, by repeated division with remainder:
Example: \(\gcd(84, 36) = \gcd(36, 12) = \gcd(12, 0) = 12\). This is much faster for very large numbers, and the app uses it to check its results.
Where LCM and GCD are used
- LCM: common denominator of fractions (\(\tfrac{1}{12} + \tfrac{1}{18}\) uses 36), events repeating with different periods, gear teeth meeting again.
- GCD: simplifying fractions (\(\tfrac{18}{30} = \tfrac{3}{5}\) after dividing by 6), cutting pieces of equal largest size, tiling.
FAQ
What does coprime mean?
Two numbers are coprime (relatively prime) when their GCD is 1, e.g. 8 and 15. Coprime numbers need not be prime themselves.
Why is the LCM of coprime numbers their product?
They share no prime, so every prime power appears in only one of them and all of them are needed: LCM(8, 15) = 120.
Can I factor a prime?
Yes – the ladder has a single row and the factorization is the prime itself.
How big can the numbers be?
Each number may have up to 12 digits. Numbers with two large prime factors take the longest; the app stops a search that would take too long and tells you.
