How to tell if a number is prime
A prime number is a whole number greater than 1 whose only divisors are 1 and itself. To check one by hand:
- If it's 2, it's prime. If it's even (and not 2) or less than 2, it isn't.
- Work out its square root. You only need to test divisors up to that point.
- Divide by each prime up to the square root: 3, 5, 7, 11, 13…
- If none divides evenly, the number is prime.
Example: is 221 prime? √221 ≈ 14.9, so test 2, 3, 5, 7, 11 and 13. 221 ÷ 13 = 17, so 221 = 13 × 17. It's composite.
Why only up to the square root? If a number has a factor bigger than its square root, it must also have one smaller than it, and you'd have found that one first.
Quick shortcuts
- Ends in 0, 2, 4, 6 or 8 (and isn't 2): divisible by 2.
- Digits add up to a multiple of 3: divisible by 3.
- Ends in 0 or 5 (and isn't 5): divisible by 5.
- Every prime above 3 is one more or one less than a multiple of 6.
More shortcuts, up to 12, are on the divisibility rules page.
How this checker works
Small numbers are checked by trial division. Larger ones use the Miller-Rabin test with the first 13 primes as bases, which is proven exact for every number below 3.3 × 10²⁴, so the answer here is never a guess. If the number is composite, it's factored with Pollard's rho method. Details are in how the checker works.
Looking for many primes at once? See the list of prime numbers or the prime numbers 1 to 100 chart.