Everyday Tools
Search

How to Check If a Number Is Prime

Last updated 2026-09-12

A prime number has exactly two divisors — 1 and itself. Here's the fastest manual method for checking, and why it works.

Rule out the obvious cases

Numbers less than 2 aren't prime. If the number is even and greater than 2, it isn't prime — it's divisible by 2.

Test divisibility up to the square root

Check whether any whole number from 2 up to the square root of your number divides it evenly. If none do, it's prime — you don't need to check any higher, since any factor larger than the square root would have to pair with one smaller than it, which you'd have already found.

Example

To check 97: √97 ≈ 9.85, so testing 2 through 9 is enough. None divide evenly, so 97 is prime.

Important Considerations

  • 1 is not prime and not composite — it has only one divisor (itself), not the two required for a prime.
  • 2 is the only even prime number, since every other even number is divisible by 2.
  • For very large numbers, trial division becomes slow — cryptography uses more efficient probabilistic tests, but trial division is exact and fine for everyday numbers.

Frequently Asked Questions

Why only check up to the square root?
If a number n has a factor larger than √n, it must also have a matching factor smaller than √n (since factors pair up to multiply to n) — so that smaller factor would already have been found.
Is 0 a prime number?
No — 0 is divisible by every number, so it doesn't meet the definition of having exactly two divisors.

Related Tools

Related Guides