How to use Prime Checker
- Enter a whole number.
- Read whether it is prime, and its factors if it is not.
- 1 is not prime, and neither is any number below it; 2 is the only even prime.
- Trial division only needs to reach the square root of the number.
- Very large numbers exceed exact integer representation in JavaScript — cryptographic-scale primality testing needs arbitrary-precision arithmetic.
How primality is actually tested
Not by trying every number below it. You only need to test divisors up to the square root, because any factor above the square root must pair with one below it — so checking up to √10000 = 100 settles a five-digit number. Skipping even numbers after 2 halves the work again, and testing only 6k±1 candidates removes multiples of 3 as well. For genuinely large numbers, trial division is hopeless and probabilistic tests such as Miller-Rabin are used instead: they can be wrong, with a probability you choose, and you make it smaller than the chance of a cosmic ray flipping the answer.
Why 1 is not prime
It looks like an arbitrary exclusion and it is a load-bearing one. The fundamental theorem of arithmetic says every integer above 1 has a unique prime factorisation — and if 1 were prime, 12 could be 2²×3 or 1×2²×3 or 1⁵×2²×3, and uniqueness would be lost. Mathematicians did count 1 as prime into the early twentieth century; it was excluded precisely because keeping it broke more theorems than it served.
The primes that keep the internet working
RSA multiplies two large primes to get a public modulus, and its security rests on factoring that product being hard while multiplying was easy. A 2048-bit RSA key uses two primes of about 300 digits each, found by generating random odd numbers and testing them — the prime number theorem says roughly one in every 700 numbers that size is prime, so this takes seconds. Nobody has factored a 2048-bit modulus, and a sufficiently large quantum computer would, which is the entire motivation for post-quantum cryptography.
Curiosities worth knowing
There are infinitely many primes — Euclid proved it around 300 BC with an argument that still fits in two lines. They thin out but never stop: the density near n is about 1/ln(n). Twin primes such as 11 and 13 appear to go on forever, but nobody has proved it. Mersenne primes, of the form 2ⁿ−1, are where the largest known primes come from, and the current record has over 41 million digits.
Frequently asked questions
What makes a number prime?
How is primality tested?
Is 1 a prime number?
What is the fastest way to check if a number is prime?
Why do prime numbers matter for encryption?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.