Prime Number Checker
Check whether a number is prime, see its prime factorization, and find the nearest primes.
97 has no divisors other than 1 and 97.
A prime number is a whole number greater than 1 whose only divisors are 1 and itself. 97 is prime — nothing between 2 and √97 ≈ 9.8 divides it. 100 is not prime: it splits as 100 = 2² × 5², so it has extra divisors and is called composite.
What makes a number prime
An integer n > 1 is prime when it cannot be written as a product of two smaller whole numbers — its only factors are 1 and n itself. Every other integer above 1 is composite and factors uniquely into primes (the fundamental theorem of arithmetic). To test n, you only need to look for a divisor up to √n: if no whole number from 2 to √n divides n evenly, then n has no factor pair at all and must be prime.
any composite n = a × b must have a factor ≤ √n, so checking past √n is unnecessary
Worked example
Check whether 97 is prime:
- 1 Confirm n is a whole number above 1. 0 and 1 are not prime, and primality is only defined for whole numbers. 97 qualifies.
- 2 Find the test bound √n. √97 ≈ 9.85, so you only need to test divisors from 2 up to 9.
- 3 Try each prime up to that bound. 97 is odd (not ÷2), digit sum 16 (not ÷3), does not end in 0 or 5 (not ÷5), and 97 ÷ 7 ≈ 13.86 (not ÷7).
- 4 No divisor means prime. Nothing from 2 to 9 divides 97 evenly, so 97 is prime. By contrast 100 ÷ 2 = 50, so 100 is composite: 100 = 2² × 5².
The first prime numbers
2 is the only even prime; every even number above 2 is divisible by 2, so it cannot be prime.
| Range | Primes |
|---|---|
| 1–10 | 2, 3, 5, 7 |
| 11–20 | 11, 13, 17, 19 |
| 21–30 | 23, 29 |
| 31–50 | 31, 37, 41, 43, 47 |
| 51–100 | 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 |
Edge cases, 1, and how primes thin out
1 is not prime. A prime must have exactly two distinct divisors; 1 has only one. Excluding 1 is also what keeps prime factorization unique, so it is a definition, not an oversight.
Trial division is exact but slow. Testing divisors up to √n always gives the right answer, and it is quick for the everyday numbers most calculators see. For numbers with hundreds of digits, cryptographic software switches to probabilistic tests like Miller–Rabin instead.
Primes thin out. There are infinitely many primes (Euclid proved it), but they grow sparser as numbers get larger: there are 4 primes below 10, 25 below 100, but only 168 below 1,000. Gaps between consecutive primes tend to widen, which is why finding the nearest prime above a large number can take several steps.