Skip to main content

Prime Number Checker

Check if any number is prime — with a deterministic Miller–Rabin test that is exact for every integer below 2⁶⁴, full prime factorization via Pollard's Rho, divisor statistics, next and previous primes, prime gaps, and an nth-prime finder. Free, instant, and 100% client-side: your numbers never leave your browser.

Big integers are handled with exact BigInt arithmetic — no floating-point rounding, ever.

Prime factorization
Step-by-step divisibility check
Divisor statistics
Number of divisors τ(n)
Sum of divisors σ(n)
Digits
Parity
All divisors
Neighboring primes
Previous prime
Next prime
Nth prime finder

Find the n-th prime number (n from 1 to 1,000,000 — e.g. the 25th prime is 97).

List primes in range

Generate every prime number between two values using the Sieve of Eratosthenes (range span up to 1,000,000).

How the primality test works

  1. Enter an integer up to 2⁶⁴ − 1 (18,446,744,073,709,551,615), or click a preset to try instantly.
  2. Trial division first. Small prime divisors (2, 3, 5, …) are tested first — this instantly resolves most composite numbers and finds the smallest prime factor.
  3. Deterministic Miller–Rabin. What remains is tested with the bases 2, 325, 9375, 28178, 450775, 9780504, 1795265022 — a set mathematically proven to give the exact answer for every integer below 2⁶⁴. No probabilities, no guessing.
  4. Full factorization. Composite numbers are broken down completely with Pollard's Rho algorithm, so even a 20-digit composite like 2⁶⁴ − 1 factors in well under a second.
  5. Read the result. Green means prime, red means composite (with the reason shown: the smallest divisor found), plus divisor statistics, neighboring primes, and prime gaps.

What is a prime number?

A prime number is a natural number greater than 1 whose only divisors are 1 and itself. The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. A number greater than 1 that is not prime is called composite (for example 4 = 2 x 2, 6 = 2 x 3). The numbers 0 and 1 are neither prime nor composite: 1 has only one divisor, so it fails the "exactly two divisors" test.

Two facts make primes special. First, the Fundamental Theorem of Arithmetic: every integer greater than 1 factors into primes in exactly one way (84 is always 2² x 3 x 7, never anything else). Second, Euclid proved there are infinitely many primes - no matter how far you search, there is always another one.

Why prime numbers matter

Primes are the atoms of arithmetic, but they also secure the modern internet. RSA encryption - used in HTTPS, banking, and messaging - works because multiplying two large primes is easy while factoring their product back apart is practically impossible. An RSA public key is essentially a giant semiprime; only the holder of the two secret prime factors can decrypt messages.

Primes also appear in nature (cicadas emerge on 13- and 17-year prime cycles to avoid predators) and in computing (hash tables and random generators use prime-sized tables to spread data evenly). The search for ever-larger primes continues through the volunteer GIMPS project.

Worked examples

  1. Is 97 prime? Its square root is about 9.8, so test the primes 2, 3, 5, 7. 97 is odd (not divisible by 2), its digits sum to 16 (not divisible by 3), it does not end in 0 or 5, and 97 / 7 = 13 remainder 6. No divisor found: 97 is prime - the 25th prime.
  2. Factor 84. 84 is even: 84 / 2 = 42, 42 / 2 = 21. 21 = 3 x 7. So 84 = 2² x 3 x 7, with τ(84) = (2+1)(1+1)(1+1) = 12 divisors.
  3. Is 91 prime? A classic trap. 91 is odd and its digits sum to 10, so 2, 3, and 5 fail - but 91 / 7 = 13 exactly. 91 = 7 x 13, composite.
  4. 2,147,483,647. This is 2³¹ - 1, a Mersenne prime (M31) - the largest value a signed 32-bit integer can hold, and it is prime. The checker confirms it instantly with the deterministic Miller-Rabin test.

First 100 prime numbers

The first 100 primes, ending at 541. There are exactly 25 primes below 100.

1–102357111317192329
11–2031374143475359616771
21–307379838997101103107109113
31–40127131137139149151157163167173
41–50179181191193197199211223227229
51–60233239241251257263269271277281
61–70283293307311313317331337347349
71–80353359367373379383389397401409
81–90419421431433439443449457461463
91–100467479487491499503509521523541

Frequently asked questions

No. By definition, a prime number has exactly two distinct positive divisors: 1 and itself. The number 1 has only one positive divisor, so it is neither prime nor composite — it sits in a category of its own. This is why every prime factorization starts at 2.
Yes — 97 is prime, and it is the 25th prime number. Its square root is about 9.8, so you only need to test divisibility by the primes 2, 3, 5, and 7; none of them divide 97. The previous prime is 89 and the next prime is 101.
Trial division up to the square root of n becomes impossibly slow for large n — a 20-digit number would need about ten billion divisions. This tool uses the deterministic Miller-Rabin test with the bases 2, 325, 9375, 28178, 450775, 9780504, and 1795265022, which is mathematically proven to give the correct answer for every integer below 2^64 (18,446,744,073,709,551,615). All arithmetic uses JavaScript BigInt, so there is no floating-point rounding.
Every composite number breaks down into a unique product of primes. For example, 84 = 2² × 3 × 7. This tool shows the full factorization with exponents, and for large composites it uses Pollard's Rho algorithm — the same family of methods used in serious factorization work — so even 20-digit composites factor in a fraction of a second.
A prime number has exactly two divisors, 1 and itself — examples are 2, 3, 5, 7, 11, and 13. A composite number has more than two divisors — for example 4 = 2 × 2, 6 = 2 × 3, and 15 = 3 × 5. The numbers 0 and 1 are neither prime nor composite.
Enter the number and look at the neighbors panel: the tool scans upward from n + 1, testing each odd candidate with the Miller-Rabin test until it finds a prime. For example, the next prime after 100 is 101. The difference between a number and its neighboring primes is called the prime gap.
Twin primes are pairs of primes that differ by 2, such as 11 and 13 or 17 and 19. Mersenne primes have the form 2^p − 1 where p itself is prime — for example, 8191 = 2^13 − 1 is the 5th Mersenne prime. This checker flags both properties automatically.
Use divisibility rules: check 2 (is it even?), 3 (do its digits sum to a multiple of 3?), and 5 (does it end in 0 or 5?). Then test the remaining primes up to the square root of the number. For example, to check 91 you only need to test primes up to 9.5: 91 is odd, its digits sum to 10, and it does not end in 0 or 5 - but 91 / 7 = 13, so 91 is composite. This tool automates exactly this process, plus the Miller-Rabin test for numbers far too large to check by hand.
There is no largest prime - Euclid proved around 300 BC that there are infinitely many. The largest KNOWN prime keeps changing as computers search further; the record holders are always Mersenne primes of the form 2^p - 1, discovered by the volunteer GIMPS project, with tens of millions of digits each.
Yes. Euclid proved this around 300 BC with a beautifully simple argument: assume you have a finite list of all primes, multiply them all together, and add 1. The result is not divisible by any prime on your list, so either it is prime itself or it has a prime factor you missed. Either way, the list was incomplete - so no finite list can contain all primes.
A prime gap is the difference between two consecutive primes. For example, the primes around 120 are 113 and 127, so the prime gap there is 127 - 113 = 14. Small gaps near the start (like the twin-prime gap of 2) get rarer as numbers grow, but prime gaps can be arbitrarily large - another consequence of there being infinitely many primes.
Modern encryption like RSA depends on a simple asymmetry: multiplying two large primes is easy, but factoring the product back into its primes is enormously hard. An RSA key is essentially a semiprime - the product of two secret primes, each hundreds of digits long. Anyone can encrypt with the public product, but only someone who knows the two secret prime factors can decrypt. This checker uses Pollard’s Rho, the same family of factoring algorithms researchers use to study this hardness.
An ancient algorithm for listing all primes up to a limit: write down every number from 2 to the limit, then repeatedly cross out the multiples of each prime you find, starting with 2. Whatever is never crossed out is prime. It is still the fastest practical way to generate every prime in a range, and the “List primes in range” tool on this page uses exactly this method.
Yes. Every even number larger than 2 is divisible by 2, so it cannot be prime. That makes 2 the only even prime - and the smallest prime of all. It is also why the first step of any primality test is to check divisibility by 2: it instantly eliminates half of all candidates.
Use the “List primes in range” tool above with 1 and 100: there are exactly 25 primes below 100 (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97). The first-100-primes table further down this page also shows them, ending at 541.
A semiprime is a composite number that is the product of exactly two primes (counting multiplicity), such as 15 = 3 x 5 or 49 = 7 x 7. Semiprimes with two LARGE prime factors are the foundation of RSA encryption. If this checker reports a number with exactly two prime factors, you have found a semiprime.

Free tool by NRTechStudio