Prime Number Checker

Type a whole number to find out whether it is prime. If it is not, you get its prime factors. Either way, you get the nearest primes on both sides.

How it works

A prime is a whole number above 1 that only 1 and itself divide evenly. 97 is prime. 91 is not, because 7 × 13 is 91.

The check uses the Miller-Rabin test with twelve fixed witnesses, which gives no wrong answers for numbers below 3.3 × 10^24. Every number this tool accepts is below that, so the answer is certain, not a probability.

Composite numbers are split into prime factors by trial division and then Pollard's rho method. Everything runs on this page.

How to use it

  1. 1 Type a whole number of up to 20 digits.
  2. 2 Read whether it is prime at the top.
  3. 3 If it is not, read its prime factorisation and how many divisors it has.
  4. 4 Read the previous and next primes below.

Good to know

  • The factorisation uses superscripts: 360 is 2³ × 3² × 5. The plain form 2^3 × 3^2 × 5 is shown under it for copying.
  • The number of divisors comes from the exponents: add 1 to each and multiply. 360 has 4 × 3 × 2 = 24 divisors.
  • Even numbers above 2 are never prime, and neither are numbers whose digits add up to a multiple of 3.
  • Commas and spaces in the number are ignored.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Prime numbers, factorisation, and how the check stays fast

A prime number is a whole number greater than 1 that only 1 and itself divide evenly. The first few are 2, 3, 5, 7, 11 and 13. Every other whole number above 1 is composite, which means it is a product of smaller primes. 91 looks prime at a glance, but it is 7 × 13. Every composite number splits into primes in exactly one way, apart from the order. This is the fundamental theorem of arithmetic, and it is why primes are called the building blocks of the whole numbers.

The simplest test is trial division: try every number up to the square root, and if none divides evenly, the number is prime. For 97 you try 2, 3, 5 and 7, since 11 squared is already 121. That is fine for small numbers, but for a 20-digit number the square root has 10 digits, and trying billions of divisors would freeze the page. This tool uses the Miller-Rabin test instead. It checks a few properties that every prime has, using twelve fixed test values. With those twelve values the test has been proved to give no wrong answers below about 3.3 × 10^24, so for every number this tool accepts the answer is certain.

Finding the factors of a composite number is harder than knowing that it has some. The tool first divides out small primes below 1,000. What remains is split with Pollard's rho method, which finds a factor in roughly as many steps as the square root of that factor. The hardest case under 20 digits is two 10-digit primes multiplied together, and even that takes a fraction of a second. A perfect square, such as a large prime times itself, is caught by a square root check before rho starts.

The result also lists the number of divisors and the primes on either side. The divisor count comes from the factorisation: 360 is 2³ × 3² × 5, and adding 1 to each exponent and multiplying gives 4 × 3 × 2, so 360 has 24 divisors. The neighbouring primes show how primes thin out. Below 100 they are a few apart. Near 20-digit numbers the average gap is about 46, though some gaps are much wider.

Some limits are worth knowing. The tool takes whole numbers of up to 20 digits, so it cannot test the record primes with millions of digits, or factor the 600-digit numbers used in RSA encryption. Those are hard to factor on purpose, and no known method can do it in any reasonable time. The number 1 and the number 0 are neither prime nor composite, and negative numbers are refused, because primality is defined for positive whole numbers.

Frequently asked questions

Is 1 a prime number?

No. A prime has exactly two divisors, 1 and itself. 1 has only one divisor, so it is neither prime nor composite. Leaving it out also keeps each number's prime factorisation unique.

Is 2 a prime number?

Yes. Its only divisors are 1 and 2. It is the only even prime, because every larger even number is divisible by 2.

Why is there a limit of 20 digits?

Checking whether a 20-digit number is prime is instant, but splitting it into factors can take much longer as numbers grow. Up to 20 digits, the slowest case, two 10-digit primes multiplied together, still finishes in a fraction of a second on this page.

Is the answer certain?

Yes. The Miller-Rabin test with the first twelve primes as witnesses has been checked to give no false answers below 3.3 × 10^24, and every number this tool accepts is well below that.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.