Prime Number Checker

Test whether a whole number is prime, see the first factor when it is not, and review the divisibility logic used for the result.

Supports large integers with `BigInt`, so values are not limited to normal JavaScript number precision.

Result
97 is prime

No divisors were found from 2 through 9.

Classification
Prime
Smallest Factor
None found
Search Limit
9

How The Check Works

A prime number has exactly two positive divisors: 1 and itself. This checker rejects values smaller than 2, handles 2 as a special case, then tests only odd divisors.

It stops at the integer square root of the input. If no factor exists up to that point, a larger matching factor cannot exist without a smaller paired factor.

Quick Examples

2 is prime because its only positive divisors are 1 and 2.
17 is prime because no whole number from 2 to 4 divides it evenly.
21 is composite because 21 = 3 × 7.
221 is composite because 221 = 13 × 17.

Frequently Asked Questions

Is 1 a prime number?

No. A prime number must have exactly two positive divisors. The number 1 has only one positive divisor: itself.

Why do you stop at the square root?

If a number has a factor larger than its square root, the paired factor must be smaller than the square root, so it would already have been found.

Are negative numbers prime?

No. Prime numbers are defined in the positive integers greater than 1.

Can very large values take longer?

Yes. Trial division is simple and reliable, but large odd integers with no small factors require more checks before the result is known.

Useful Notes

All even numbers greater than 2 are composite.

Every composite number can be written as a product of prime numbers.

Prime checks show up in cryptography, hashing strategies, and number theory exercises.

Related Tools