Skip to content

DIY Cost Tools

Prime Number Calculator

MATH CALCULATOR

Check whether a positive whole number is prime and find the closest previous and next prime numbers.

ClassificationPrime
Smallest factorNone other than 1 and 97
Previous prime89
Next prime101

How it works

A prime number is a whole number greater than 1 with exactly two positive factors: 1 and itself. Testing possible divisors only through √n is sufficient.

Method

If no integer from 2 through √n divides n evenly, then n is prime.

Example

97 is prime because none of the possible divisors through √97 divides it evenly. The surrounding primes are 89 and 101.

Important limits

  • Zero and one are neither prime nor composite.
  • The browser check is capped at one billion for responsive performance.
  • Negative integers are not classified as prime in the usual elementary definition.

Frequently asked questions

Is 2 prime?

Yes. It is the smallest prime and the only even prime number.

Why stop testing at the square root?

If a composite number has a factor larger than its square root, its paired factor must be smaller than the square root.

Review notes

The test uses exact integer divisibility through the input’s square root. Last reviewed September 30, 2026.

Related calculators