UsefulVerse guide

How to Check if a Number Is Prime

A prime-number test asks whether a whole number greater than 1 has any divisors besides 1 and itself. This guide shows a reliable way to check a number and explains what the result does—and does not—tell you.

Know the definition first

A prime number is a whole number greater than 1 with exactly two positive divisors: 1 and the number itself. The first primes are 2, 3, 5, 7, 11 and 13. The number 1 is neither prime nor composite, and 2 is the only even prime.

Check only up to the square root

To test a positive integer n, you do not need to try every number below n. If n has a factor larger than its square root, it must also have a matching factor smaller than the square root. So testing possible divisors up to the square root is enough.

  1. If the number is less than 2, it is not prime.
  2. Check whether it is divisible by 2. If it is even and greater than 2, it is not prime.
  3. Try odd divisors from 3 up to the square root. If any divides evenly, the number is composite.
  4. If none divides evenly, the number is prime.

Example: is 97 prime?

The square root of 97 is a little less than 10. Check the possible prime divisors up to that point: 2, 3, 5 and 7. The number is not divisible by any of them, so 97 is prime.

For 91, the check finds 7: 91 ÷ 7 = 13. That is enough to show that 91 is composite; there is no need to test larger divisors.

Common mistakes

  • Calling 1 prime. A prime must have exactly two positive divisors, while 1 has only one.
  • Assuming every odd number is prime. Odd composites such as 9, 15, 21 and 91 have odd divisors.
  • Testing only a few small divisors for a large number. The check must cover every possible divisor up to the square root, or use a verified primality algorithm.

UsefulVerse checks practical whole-number inputs locally in your browser. A prime result is a divisibility check, not a proof about a cryptographic key or a substitute for specialized number-theory software.

Sources and further reading