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.
Find the n-th prime number (n from 1 to 1,000,000 — e.g. the 25th prime is 97).
Generate every prime number between two values using the Sieve of Eratosthenes (range span up to 1,000,000).
How the primality test works
- Enter an integer up to 2⁶⁴ − 1 (18,446,744,073,709,551,615), or click a preset to try instantly.
- Trial division first. Small prime divisors (2, 3, 5, …) are tested first — this instantly resolves most composite numbers and finds the smallest prime factor.
- 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. - 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.
- 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
- 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.
- 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.
- 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.
- 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–10 | 2 | 3 | 5 | 7 | 11 | 13 | 17 | 19 | 23 | 29 |
|---|---|---|---|---|---|---|---|---|---|---|
| 11–20 | 31 | 37 | 41 | 43 | 47 | 53 | 59 | 61 | 67 | 71 |
| 21–30 | 73 | 79 | 83 | 89 | 97 | 101 | 103 | 107 | 109 | 113 |
| 31–40 | 127 | 131 | 137 | 139 | 149 | 151 | 157 | 163 | 167 | 173 |
| 41–50 | 179 | 181 | 191 | 193 | 197 | 199 | 211 | 223 | 227 | 229 |
| 51–60 | 233 | 239 | 241 | 251 | 257 | 263 | 269 | 271 | 277 | 281 |
| 61–70 | 283 | 293 | 307 | 311 | 313 | 317 | 331 | 337 | 347 | 349 |
| 71–80 | 353 | 359 | 367 | 373 | 379 | 383 | 389 | 397 | 401 | 409 |
| 81–90 | 419 | 421 | 431 | 433 | 439 | 443 | 449 | 457 | 461 | 463 |
| 91–100 | 467 | 479 | 487 | 491 | 499 | 503 | 509 | 521 | 523 | 541 |
Frequently asked questions
Free tool by NRTechStudio