Prime Number Checker
Prime or composite verdict, divisors, and next prime.
What it does
Primality testing divides by candidates up to the square root: any factor larger pairs with a smaller one already tested, so the root bounds the search. Ninety seven needs checks only to ten.
The tool above tests numbers to a billion. It returns the verdict, every divisor, and the next prime upward.
One and zero sit outside both camps by definition, since primes need exactly two divisors. Two stands alone as the only even prime.
Huge primes guard the internet through RSA, where multiplying two secret primes is easy but factoring the product is practically impossible. Everyday checks like this one use the same trial division at small scale.
How to use
- Enter a whole number from zero to a billion.
- Read the verdict first.
- Scan divisors for factor work.
- Take the next prime for sequences and keys.
Formula
- sqrt(n)
- Search bound. Larger factors pair smaller ones.
- i, n/i
- Divisor pairs collected together.
Probabilistic tests like Miller-Rabin handle thousand digit giants where trial division dies. Exact division rules school sized numbers.
Worked example
Example: is 97 prime?
Number 97.
- Root: sqrt(97) = 9.85, so test 2 through 9.
- 97 mod 2, 3, 5, 7 all leave remainders. Four and six-plus divide by two already.
- No divisors found: 97 is prime.
- Divisors: 1, 97. Next prime: 101.
Reference table
| Count | Primes |
|---|---|
| First 5 | 2, 3, 5, 7, 11 |
| To 30 | 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 |
| Tenth prime | 29 |
| 25th prime | 97 |
| 100th prime | 541 |
Limits
- Zero to a billion modeled. Larger needs stronger tests.
- Next prime scan caps at reasonable distance.
- Negatives rejected; sign carries no primality.
- Decimals round to whole numbers first.
Common mistakes
- Calling one prime. It has a single divisor.
- Calling all odds prime. Nine and fifteen disagree.
- Testing past the square root wastefully.
- Forgetting two is prime.
- Assuming large odds are prime.
Try it yourself
Quick checks. Answers sit tucked under each question.
Is 51 prime?
No: 51 = 3 x 17. Divisors 1, 3, 17, 51.
Next prime after 14?
17, since 15 and 16 divide.
Questions
Is 1 prime?
No. Primes need exactly two divisors; one has a single divisor.
Is 2 prime?
Yes, the only even prime and the smallest of all.
How do I test big numbers?
Divide to the square root. No divisors there means prime.
Why do primes matter?
Encryption, hashing, and cicada-free gear ratios all lean on them.
What is the largest prime?
Mersenne giants with tens of millions of digits, still growing by search.
Are there infinite primes?
Yes, proved by Euclid: multiply known primes, add one, repeat.