Prime Number Checker

Prime or composite verdict, divisors, and next prime.

Math and PercentUpdated 2026-10-101 min read
Prime Number Checker
Verdict
...
Divisors...
Next prime...

What it does

Primality testing divides by candidates up to the square root: any factor larger pairs with a smaller one already tested, so the root bounds the search. Ninety seven needs checks only to ten.

The tool above tests numbers to a billion. It returns the verdict, every divisor, and the next prime upward.

One and zero sit outside both camps by definition, since primes need exactly two divisors. Two stands alone as the only even prime.

Huge primes guard the internet through RSA, where multiplying two secret primes is easy but factoring the product is practically impossible. Everyday checks like this one use the same trial division at small scale.

How to use

  1. Enter a whole number from zero to a billion.
  2. Read the verdict first.
  3. Scan divisors for factor work.
  4. Take the next prime for sequences and keys.

Formula

Trial division: if no d from 2 to sqrt(n) divides n, n is prime. Divisors pair as i and n/i.
sqrt(n)
Search bound. Larger factors pair smaller ones.
i, n/i
Divisor pairs collected together.

Probabilistic tests like Miller-Rabin handle thousand digit giants where trial division dies. Exact division rules school sized numbers.

Worked example

Example: is 97 prime?

Number 97.

  1. Root: sqrt(97) = 9.85, so test 2 through 9.
  2. 97 mod 2, 3, 5, 7 all leave remainders. Four and six-plus divide by two already.
  3. No divisors found: 97 is prime.
  4. Divisors: 1, 97. Next prime: 101.

Reference table

First primes for reference
CountPrimes
First 52, 3, 5, 7, 11
To 302, 3, 5, 7, 11, 13, 17, 19, 23, 29
Tenth prime29
25th prime97
100th prime541

Limits

  • Zero to a billion modeled. Larger needs stronger tests.
  • Next prime scan caps at reasonable distance.
  • Negatives rejected; sign carries no primality.
  • Decimals round to whole numbers first.

Common mistakes

  • Calling one prime. It has a single divisor.
  • Calling all odds prime. Nine and fifteen disagree.
  • Testing past the square root wastefully.
  • Forgetting two is prime.
  • Assuming large odds are prime.

Try it yourself

Quick checks. Answers sit tucked under each question.

Is 51 prime?

No: 51 = 3 x 17. Divisors 1, 3, 17, 51.

Next prime after 14?

17, since 15 and 16 divide.

Questions

Is 1 prime?

No. Primes need exactly two divisors; one has a single divisor.

Is 2 prime?

Yes, the only even prime and the smallest of all.

How do I test big numbers?

Divide to the square root. No divisors there means prime.

Why do primes matter?

Encryption, hashing, and cicada-free gear ratios all lean on them.

What is the largest prime?

Mersenne giants with tens of millions of digits, still growing by search.

Are there infinite primes?

Yes, proved by Euclid: multiply known primes, add one, repeat.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.