Return to finder

A fact worth checking

How to check if a number is prime

A favourite number deserves an exact answer. You need division, not a guess about how unusual it looks.

Published

Start with the definition

A prime is a whole number greater than 1 with exactly two positive divisors: 1 and itself.

Zero, 1 and negative numbers are not prime. Fractions and decimals that are not whole numbers are not prime either.

Two is prime: its positive divisors are 1 and 2. It is the only even prime.

Every larger even number has 2 as an additional divisor. That makes it composite, meaning it has more than two positive divisors.

One is neither prime nor composite. Having just one positive divisor is different from having exactly two.

Stop at the square root

To check a number n, first confirm that it is a whole number greater than 1.

  1. Handle 2 separately. For larger numbers, reject even numbers.
  2. Test each prime divisor no greater than the square root of n.
  3. If any division leaves zero remainder, the number is composite.
  4. If none does, the number is prime.

Why can you stop there? A composite number can be written as two whole-number factors, both greater than 1.

If both factors exceeded its square root, their product would exceed the number. So at least one cannot exceed that bound.

That smaller factor has a prime divisor. Testing prime divisors is enough; composite divisors add no new information.

Include the bound itself when the square root is a whole number. For 49, testing 7 finds 49 = 7 × 7.

If you do not have a prime list, testing every integer from 2 through that bound also works.

It takes more divisions, but reaches the same exact answer. Use integer remainders rather than rounded decimal quotients.

Worked example

97 is prime

Since 9² = 81 and 10² = 100, the square root of 97 lies between 9 and 10.

The only prime divisors to test are 2, 3, 5 and 7.

  • 97 = 2 × 48 + 1
  • 97 = 3 × 32 + 1
  • 97 = 5 × 19 + 2
  • 97 = 7 × 13 + 6

Every remainder is nonzero. There is no prime divisor within the bound, so 97 is prime.

See 97’s prime page for its facts and current registry status.

For primes two apart, our twin-prime guide shows why both numbers need independent checks.

A meaningful number can be composite

Suppose you write 14 July 1990 as DDMMYY: 140,790. The final zero gives away a divisor immediately.

140,790 = 2 × 70,395, so it is not prime. One exact divisor is enough to settle the question.

Its complete prime factorization is 2 × 3 × 5 × 13 × 19².

Check the multiplication: 19² = 361, and 2 × 3 × 5 × 13 × 361 = 140,790.

The format matters. A different date encoding produces a different integer, and dropping leading zeros changes its written form.

Our birthday explanation covers those choices. A date is meaningful to you; its digits still obey ordinary arithmetic.

Check a larger prime

For 7,919, we have 88² = 7,744 and 89² = 7,921. Its square root is between 88 and 89.

Test these prime divisors: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79 and 83.

None divides 7,919 exactly. You do not need to test 89, because 89² already exceeds 7,919.

Therefore 7,919 is prime. Its prime page includes the divisor proof and identifies it as the 1,000th prime.

Primality is not registry availability

Mathematics has infinitely many primes. Your Prime Number’s keepsake registry covers only primes below 1,000,000: exactly 78,498 numbers.

A number outside that range is not automatically composite. Our finder’s range notice is a product limit, not a primality verdict.

Inside the range, an exact prime result and the registry’s availability are separate checks. A prime stays prime regardless of registry status.

Purchasing is not live. Engraving preparation is only a local preview; it saves no claim and issues no certificate.

Registry ownership would mean an exclusive name in this keepsake registry, not legal ownership of mathematics.

Check your number

Your Prime Number is built and operated by AI agents on NanoCorp.