About the Prime Number Checker
A prime number has exactly two divisors: 1 and itself. 7 is prime because nothing between 1 and 7 divides it. 9 is not, because 3 does — giving it three divisors rather than two.
That "exactly two" is doing real work. It is why 1 is excluded: it has only one divisor, itself. And it is why 2 is prime despite being even — nothing else divides it.
Primes matter because every other whole number is built from them, uniquely. They are the atoms of arithmetic. They are also the foundation of modern encryption, for a reason that comes down to a single asymmetry: multiplying two large primes is instant, and pulling them back apart is, as far as anyone knows, impossible at scale.
This checker tells you whether a number is prime and — more usefully — why. A bare "no" teaches nothing; being shown that 91 = 7 × 13 does.
How to Use the Prime Number Checker
Is this number prime? takes any whole number. You get a verdict, the reason, and the nearest primes either side. When the answer is no, the reason names the divisor that settles it and shows the full factorisation.
List the primes in a range takes a start and an end, up to 10,000 numbers apart. You get every prime in between, the count, and any twin prime pairs.
How Primality Is Tested
The naive method is to try every number from 2 up to n−1. It works and it is wildly wasteful.
Two observations make it fast.
Only test up to the square root. Divisors come in pairs that multiply to n. If both members of a pair were larger than √n, their product would be larger than n, which is impossible. So if any divisor exists, the smaller one is at or below the square root. Testing beyond it finds nothing new.
For 97 that means testing up to 9.85 — just 2, 3, 5 and 7. Four tests instead of ninety-five.
Only test primes. If 4 divided the number, 2 would have already. Once 2 is ruled out, every even number can be skipped, which halves the work immediately.
For listing a range, testing each candidate separately is the wrong approach. The sieve of Eratosthenes is far better: write out every number, then cross off multiples of 2, then multiples of 3, then 5, and so on. Whatever survives is prime. It replaces division with counting, and it is over two thousand years old.
The same square-root bound applies: you only need to sieve using primes up to √n, because any composite below n has a factor below its own square root.
Primality Formula
n is prime when:
n >= 2, and no whole number d with 2 <= d <= √n divides n
Equivalently:
n has exactly two distinct divisors
Sieve of Eratosthenes for all primes up to N:
mark every number 2..N as prime
for p = 2 while p² <= N:
if p is still marked, strike out p², p²+p, p²+2p, ...
what remains is the list of primes
The sieve starts crossing off at p² rather than 2p because everything smaller has already been struck by an earlier prime.
There are also probabilistic tests — Miller–Rabin and similar — used for the enormous numbers in cryptography, where trial division is hopeless. They can be wrong with vanishingly small probability, which for practical purposes is a trade worth making.
Step-by-Step Example
Is 97 prime?
Step 1 — find the bound. √97 ≈ 9.85, so test up to 9.
Step 2 — test 2. 97 is odd. No.
Step 3 — test 3. Digits sum to 16, not a multiple of 3. No.
Step 4 — test 5. Does not end in 0 or 5. No.
Step 5 — test 7. 7 × 13 = 91, 7 × 14 = 98. No.
Nothing below 9.85 divides it, so nothing above can either. 97 is prime — and it took four tests.
Now the contrasting case. Is 91 prime?
√91 ≈ 9.54
2? 91 is odd. No.
3? digits sum to 10. No.
5? ends in 1. No.
7? 7 x 13 = 91. Yes.
91 is not prime. It looks prime — it is odd, it is not obviously divisible — which is exactly why it appears so often as a trick question. 7 × 13 is the sort of factorisation people forget to check.
Understanding Your Result
The verdict is the answer.
The why is the part worth reading. For a composite it names the divisor found and, in the working, gives the complete factorisation. For a prime it states the square-root bound and that nothing below it divided.
The nearest primes show the closest prime either side. Primes thin out as numbers grow — there are 25 below 100, 168 below 1,000, and 1,229 below 10,000 — so those gaps widen. When the gap is exactly 2, the pair is flagged as a twin prime.
In list mode, the twin pairs are collected separately. Whether twin primes go on forever is an open question: they keep appearing as far as anyone has looked, but nobody has proved they never stop.
One useful fact the checker demonstrates repeatedly: the number of tests needed is small. Confirming a six-digit prime takes a few hundred divisions.
When Should You Use This Calculator?
Checking homework. "Is 91 prime?" is a standard question, and the answer is more instructive with the divisor attached.
Simplifying fractions. A prime numerator or denominator often means the fraction will not reduce.
Finding factors. If a number is prime, there is nothing to factorise and you can stop looking.
Number theory exercises. Twin primes, prime gaps, prime counting — the list mode makes these explorable.
Understanding cryptography. RSA keys are built from large primes. Seeing how quickly a six-digit number can be tested, and how hopeless factorising a 600-digit one would be, makes the asymmetry concrete.
Hash tables and algorithms. Prime-sized tables reduce collision clustering, so "what is the next prime above 1000?" is a real engineering question.
Common Mistakes
Thinking 1 is prime. It has one divisor, not two. Excluding it is what keeps prime factorisation unique.
Thinking 2 is not prime because it is even. Evenness is irrelevant; what matters is the divisor count. 2 has exactly two divisors and qualifies. It is the only even prime, because every other even number has 2 as a third divisor.
Assuming all odd numbers are prime. 9, 15, 21, 25, 27 and 33 are all odd and all composite.
Testing every number up to n. Stop at √n. For a million that is the difference between a million tests and a thousand.
Testing composites as divisors. Once 2 is ruled out, 4, 6 and 8 cannot divide. Odd numbers only, after the first test.
Missing the 7 × 13 cases. Numbers like 91, 119 and 187 look prime to the eye. They are products of two primes in the teens, and they catch people out constantly.
Believing there is a formula for primes. There is no simple expression that generates them all. Their distribution has deep structure — the prime number theorem describes how they thin out — but no closed form produces the sequence.