How to Check If a Number Is Prime
A prime number has exactly two divisors: one and itself. The Prime Number Checker tests any number instantly, and the method behind it is worth knowing because it is a genuinely elegant shortcut.
You only need to go up to the square root
To check whether 97 is prime, you do not test every number up to 96. You test up to the square root of 97, which is just under 10 - so 2 through 9, and you are done.
The reason is simple once you see it. If a number has a divisor larger than its square root, it must also have one smaller than its square root, because the two multiply to give the number. 100 divides by 20, and therefore also by 5. So any divisor you would find above the square root has a partner you already found below it.
That turns an apparently enormous job into a small one. Checking a six-digit number means testing up to about 1,000 rather than up to a million.
Shrinking it further
You can skip almost everything. Test 2, then test only odd numbers - if it is not divisible by 2, it is not divisible by any even number.
Better still, every prime above 3 is of the form 6k plus or minus 1, so after checking 2 and 3 you can test only numbers one either side of each multiple of six. That eliminates two-thirds of the candidates before you start.
For 97: not even, digits sum to 16 so not divisible by 3, does not end in 0 or 5, and 7 times 13 is 91 and 7 times 14 is 98 - so no. Prime, in four checks.
The divisibility rules worth having
2: ends in an even digit. 3: digits sum to a multiple of 3. 5: ends in 0 or 5. 9: digits sum to a multiple of 9. 11: alternating sum of digits is a multiple of 11.
Those five catch a large share of composite numbers without any division at all.
Two things worth knowing
1 is not prime. It has only one divisor, not two. This is a definition chosen deliberately - if 1 were prime, every number would have infinitely many prime factorisations, and the uniqueness of prime factorisation is the foundation of most of number theory.
2 is prime, and it is the only even prime, which makes it the exception in nearly every rule about primes.
Why anyone cares
Primes are the atoms of multiplication - every whole number above 1 factors into primes in exactly one way. That underpins the LCM and GCD Calculator, and it is why fractions simplify the way they do.
And modern encryption rests on the fact that multiplying two large primes is easy while factoring the result back is not - which is the whole asymmetry that makes public-key cryptography possible.
Common questions
What is the largest known prime?
They keep getting found - the record is in the tens of millions of digits, discovered by distributed computing projects.
How many primes are there?
Infinitely many. Euclid proved it over two thousand years ago.
Are there patterns in the primes?
They thin out predictably and their individual positions look irregular. Twin primes - pairs two apart - are an open question.
Got a number to check?