Skip to content
Toolew.com

Prime Number Checker

Check whether numbers of up to 400 digits are prime, factorise composites, find neighbouring primes and list primes in a range.

Runs in your browser. Your data is not uploaded.
Loading tool…

This guide is not yet available in your language and is shown in English.

Tool guide

What this tool does

The Prime Number Checker tests one or hundreds of numbers at once with the Miller-Rabin algorithm, which is deterministic for numbers below 3.18 × 10^23. Composite numbers are factorised, single numbers show the next and previous primes, and a range mode lists every prime between two bounds using a sieve.

A prime number is a whole number greater than 1 whose only divisors are 1 and itself. Testing small numbers by trial division is easy, but it becomes hopeless for numbers with 20 or more digits, which is exactly where primes matter most, in cryptography, hashing and number-theory puzzles.

This checker uses the Miller-Rabin test on arbitrary-precision integers. With the first twelve primes as witnesses the test is proven to give no false results for every number below 3.18 × 10^23; larger numbers are tested against 24 witnesses, making an error vanishingly unlikely. Composites are broken into prime factors with trial division and Pollard’s rho, and the range mode uses a segmented sieve of Eratosthenes. All of this runs locally in your browser.

How to use Prime Number Checker

  1. Choose Check numbers to test specific values, or List primes in a range.
  2. In Check mode, enter one or more whole numbers (up to 500 per batch, 400 digits each), one per line or separated by commas.
  3. Read the verdict; for a single number you also get its factorisation and the next and previous primes.
  4. In Range mode, set From and To (up to 10^12, spanning at most five million numbers) to see the count, twin primes and largest gap.
  5. Download the results table as CSV for batches or long prime lists.

Tips for better results

  • 1 is not prime and 2 is the only even prime; any other even number is composite.
  • Carmichael numbers such as 561 fool the simple Fermat test but are correctly identified here as 3 × 11 × 17.
  • Mersenne numbers 2^p − 1 make good tests: 2^31 − 1 = 2,147,483,647 is prime, 2^11 − 1 = 2047 = 23 × 89 is not.

Common use cases

  • Checking homework on primes, factor trees and divisibility.
  • Choosing prime table sizes or moduli such as 1,000,000,007 for hashing and programming contests.
  • Exploring twin primes and prime gaps over a range.
  • Verifying small RSA examples in a cryptography course.

Common mistakes to avoid

  • Calling 1 a prime number; by definition primes must have exactly two distinct divisors.
  • Assuming numbers ending in 1, 3, 7 or 9 are prime; 91 = 7 × 13.
  • Relying on a Fermat test alone, which Carmichael numbers can pass.

Frequently asked questions

Is the Miller-Rabin result guaranteed?

For numbers below 3.18 × 10^23 the chosen witnesses make the test deterministic, so the answer is proven. Above that the test is probabilistic with 24 witnesses, and the chance of a composite slipping through is below 4^−24.

Why is 1 not a prime number?

A prime must have exactly two distinct positive divisors. 1 has only one. Excluding it also keeps prime factorisations unique.

How many primes can the range mode list?

It sieves up to five million consecutive numbers below 10^12. The page shows the first 2,000 primes and the downloadable table includes up to 20,000.

Can it factorise very large numbers?

It fully factorises most numbers up to about 25 digits within moments. Larger composites with two big prime factors may show an unsplit composite part in brackets, because factoring them is genuinely hard.

Feedback & suggestions

Help us improve Prime Number Checker. We read every message.

Rating (optional)
Necessary
Required for security, language and theme preferences. Always on.