Prime Numbers
Check whether any number is prime, see its prime factorisation and the nearest primes either side, then list every prime up to a limit you choose.
How to use it
- Type a number to test it — the verdict and factorisation appear instantly.
- Composite numbers show their full prime factorisation.
- The second panel lists every prime up to your limit using the sieve of Eratosthenes.
Examples
| 97 | Prime |
| 91 | Composite — 7 × 13 |
| Primes below 100 | 25 of them |
A prime number has exactly two positive divisors — 1 and itself. Every other whole number above 1 is composite, meaning it can be broken down into smaller prime factors, and by the fundamental theorem of arithmetic that breakdown is unique: 60 is 2 × 2 × 3 × 5 and no other combination of primes multiplies to 60.
This checker tests any number instantly, shows its full factorisation if it is composite, and lists every prime up to a limit you set using the sieve of Eratosthenes — the same algorithm computers have used for the job since well before electronic computing existed.
How the primality test works
The straightforward way to check a number n is to try dividing it by every integer from 2 up to √n. If none divide evenly, n is prime. The square root cutoff is not a shortcut for speed alone — it is a proof: if n = a × b and both a and b were greater than √n, their product would exceed n, which is a contradiction. So a composite number is guaranteed to have a factor at or below its square root.
That keeps the test fast even for large numbers. Checking 999,983 (which is prime) only needs trial division up to 1,000, not up to a million.
The sieve of Eratosthenes
Listing every prime up to a limit uses a different, older method, credited to the Greek mathematician Eratosthenes around 240 BC. Write out every number up to the limit, then starting from 2, cross out every multiple of 2, then every multiple of the next surviving number, and so on. Whatever is left uncrossed is prime.
It is faster than testing each number individually because it never repeats work — once 2 has crossed out every even number, nothing else needs to check divisibility by 2 again.
Facts worth knowing
| Fact | Detail |
|---|---|
| Smallest prime | 2 — the only even prime, since every other even number divides by 2 |
| Primes under 100 | 25 of them: 2, 3, 5, 7, … up to 97 |
| Primes under 1,000 | 168 |
| Twin primes | Pairs differing by 2, such as 11 and 13, or 17 and 19 |
| Largest known prime (2024) | A Mersenne prime with over 41 million digits |
Where primes actually get used
- RSA and other public-key encryption, which relies on multiplying two large primes together being easy, but factoring the result back apart being computationally hard.
- Hash tables and hashing algorithms, where a prime table size reduces clustering of keys.
- Cryptographic hash functions and random number generators.
- Pure mathematics — primes are the building blocks every other integer is made from.
Questions people ask
Why is 1 not a prime number?
Because a prime has exactly two distinct divisors, and 1 has only one. Excluding it also keeps prime factorisation unique — otherwise you could pad any factorisation with as many 1s as you liked.
Why only check divisors up to the square root?
If n = a × b and both were larger than √n, their product would exceed n. So any composite number must have a factor at or below its square root.
What are twin primes?
Primes that differ by two, like 11 and 13. The list counts them for you. Whether there are infinitely many is still an open problem.
Does this page need an internet connection?
Only the first time. The whole table is part of the page, and the service worker caches it, so it keeps working offline afterwards.
Last updated 22 August 2026