Prime Factorization · GCD · LCM
Enter one or two positive integers. For each: the prime factorization in `p^e × q^f` form, every divisor, and whether the number itself is prime. Enter both and you also get GCD (greatest common divisor — useful for reducing fractions) and LCM (least common multiple — useful for finding a common period). Trial division up to √n is fast enough for numbers up to ~10¹² and runs entirely in your browser.
GCD (greatest common divisor)
36
LCM (least common multiple)
2520
360
Prime factorization
2^3 × 3^2 × 5
Divisors (24)
1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, 60, 72, 90, 120, 180, 360
252
Prime factorization
2^2 × 3^2 × 7
Divisors (18)
1, 2, 3, 4, 6, 7, 9, 12, 14, 18, 21, 28, 36, 42, 63, 84, 126, 252
Trial division up to √n. Fast for inputs up to ~10¹². Divisor scan is skipped above 10⁹ to stay snappy.
How to use
- Enter a number in field A for factorization, divisors, and primality.
- Add a second number in field B to also compute GCD and LCM.
- Copy the factorization or read the divisor list. Divisor list capped at first 200 for very composite numbers.
Frequently asked questions
- What's the largest input?
- Up to about 10¹² (a trillion). Above that, JavaScript loses integer precision (Number.MAX_SAFE_INTEGER is 2⁵³ ≈ 9×10¹²), and trial division to √n starts getting slow. For bigger numbers you'd need BigInt and Pollard's rho.
- Why no divisor list for large numbers?
- We cap the divisor scan at n < 10⁹ to avoid pegging your CPU. The prime factorization still runs because it's O(√n) by the largest prime factor, often much less than n itself.
- What's GCD good for?
- Reducing fractions: 252/360 = ?. GCD(252, 360) = 36, so 252/360 = 7/10. Also used in cryptography (RSA), and to determine whether two cycles will ever align.
- Is LCM(a, b) = a × b / GCD(a, b)?
- Yes, always, for positive integers. We use exactly that identity. The intuition: LCM has every prime factor at its highest power across a and b; GCD has every prime factor at its lowest power; multiplying recovers a × b.
Related tools
Linear Regression Calculator
Paste (x, y) pairs and instantly get the best-fit line — slope, intercept, Pearson r, R², and a live prediction — all computed in your browser.
Percentage Calculator
Work out percentages, what-percent, and percent change in one place.
Tip Calculator
Calculate the tip and split the total bill between people.
Tile Calculator
Work out how many floor or wall tiles you need for a room — from its length and width and the tile size, with an adjustable waste allowance and boxes required.
BMI Calculator
Calculate Body Mass Index from height and weight, with a healthy range.
Age Calculator
Calculate exact age in years, months, days — and find your next birthday.