Skip to main content
NyankoTools

Prime Factorization, GCD and LCM Calculator

Break an integer into a product of primes and see all its divisors, the divisor count and sum, and whether it is prime. Enter several integers to get their greatest common divisor and least common multiple. Large integers beyond normal JavaScript numbers are computed exactly with BigInt. To simplify a ratio, try the Ratio & Percentage Calculator; for binary or hexadecimal, use the Base Converter.

🔒 Runs in your browser · Your data is never sent to a server

Notes

  • Factorization uses trial division by small primes, then Pollard's rho and Miller-Rabin. Huge integers with two or more large prime factors (roughly a product of primes of a dozen or more digits each) may not finish in time. In that case the tool says it could not factor the number and shows no partial result.
  • Inputs must be integers of 1 or more, up to 60 digits. Zero, negative numbers and decimals are errors. For factorization, 1 is also rejected because it has no prime factors.
  • Thousands separators (commas) are ignored in the factorization input. In the GCD / LCM input a comma separates values, so do not use thousands separators there (1,000 would be read as 1 and 000, and 000 is an error).
  • If a number has more than 5000 divisors, the list is omitted and only the count and sum are shown.
  • In the result, "^" means a power (2^3 = 2×2×2).

Glossary

Prime factorization

Writing an integer greater than 1 as a product of primes. Apart from order, every integer has exactly one such form (360 = 2^3 × 3^2 × 5).

GCD and LCM

The greatest common divisor is the largest integer that divides all the numbers; the least common multiple is the smallest positive integer that all of them divide. For two numbers a and b, a × b = GCD × LCM.

Coprime

Integers whose GCD is 1. They share no prime factor, so a fraction a/b cannot be reduced any further.

Divisor count and sum

If the factorization is p^a × q^b × …, the number of divisors is (a+1)(b+1)…. The sum is the product, over each prime, of 1 + p + … + p^a.

FAQ

How large an integer can it factor?

Input is limited to 60 digits, but whether a number can actually be factored depends on its structure. Numbers with many small factors finish instantly even at 60 digits, while a product of two large primes of a dozen or more digits each may not finish in a browser. In that case the tool says it could not factor the number instead of showing a partial result.

Why are 0 and 1 rejected?

Zero cannot be factored. 1 is neither prime nor composite and has no prime factors, so factorization needs an integer of 2 or more. For GCD and LCM, zero is also rejected because the LCM with zero is awkward to define.

Can I find the GCD and LCM of three or more numbers?

Yes. Enter two or more integers (up to 1000) separated by commas, spaces or new lines. The LCM is computed exactly with BigInt even when it gets huge. Thousands-separator commas cannot be used there, because a comma is a value separator.

Why is the divisor list sometimes missing?

When a number has more than 5000 divisors, the list would be very long, so only the count and sum are shown. The count is the product of (exponent + 1) over the prime factors.

Is the primality result certain?

Below about 3.3×10^24 the Miller-Rabin test used here is deterministic, so the result is certain. For prime factors above that it is probabilistic, and the page shows a notice. The chance of a wrong answer is negligible in practice.

Share this page

↑↓ Select Enter Open Esc Close