Prime Number Checker — Is It Prime?
Enter any positive integer to test for primality. The tool also shows the next and previous primes, and the prime factorisation if the number is composite.
What is a prime number?
A prime number is a positive integer greater than 1 whose only divisors are 1 and itself. The first few primes: 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. There are infinitely many primes (Euclid's theorem) and they form the building blocks of all integers via the fundamental theorem of arithmetic — every integer greater than 1 is either prime or can be uniquely factorised as a product of primes.
Why primes matter
- Cryptography — RSA, Diffie-Hellman and many other crypto algorithms depend on the difficulty of factorising large composites into their primes.
- Hash functions — many hash table sizes are chosen as primes to reduce collision rates.
- Coding theory — primes appear in error-correcting codes and number-theoretic transforms.
- Mathematics — primes are central to number theory and analytic number theory.
- Random number generators — many PRNGs use prime moduli.
How this checker works
For numbers up to a few billion, the tool uses optimised trial division up to the square root of N. For numbers from a few billion up to JavaScript's safe-integer limit (2^53 − 1), it uses a deterministic Miller-Rabin primality test with witnesses chosen to be correct for all 64-bit integers. The result is exact, not probabilistic.
If the number is composite, the prime factorisation is also computed and displayed.
Tips
- 2 is the only even prime — every other prime is odd.
- 3, 5, 7 are the only "single-digit" primes beyond 2.
- Primes get sparser as numbers grow — among the first 100 integers, 25 are prime; among the first million, 78,498 are.
- The "primes ending in 1, 3, 7, 9" rule covers all primes greater than 5 (since 2 and 5 are the only primes that don't fit).
FAQs
Is 1 prime?
No — by modern convention, 1 is not prime. It's a "unit" but not a prime.
Is 0 prime?
No — primes are positive integers greater than 1.
What's the largest known prime?
As of 2026, it's a Mersenne prime with over 24 million digits. The Great Internet Mersenne Prime Search (GIMPS) finds new ones.
How fast is this for very large numbers?
Numbers up to 2^53 check in well under a second using Miller-Rabin.
Is anything uploaded?
No.