Is it prime?

Yes, 97 is prime

A prime number greater than 1 has no whole-number factors other than 1 and itself.

How it works

A number greater than 1 is checked for any whole-number factor other than 1 and itself. If none exists, it is prime.

Take 97. The divisor 2 is ruled out at once because 97 is odd, and the remaining divisors below its square root of about 9.85 are 3, 5, 7 and 9. None divides 97 evenly: they leave remainders of 1, 2, 6 and 7 respectively. The next odd number to try would be 11, but 11 × 11 = 121 is already past 97, so the search stops there and the answer is prime. Stopping at the square root is what keeps the work short: a number in the tens of thousands needs a few dozen trials instead of a few thousand. The complementary question, which divisors a number does have, is answered by the Factors Calculator.

Primality concerns a single number, but the neighbouring question concerns a pair: what two numbers have in common. Because a prime number has only the factors 1 and itself, two different primes share nothing but 1, so their greatest common divisor is exactly 1. The GCD & LCM Calculator builds on that fact, and the guide to factors and primes sets primality and factorisation out together.

Formula: A prime number greater than 1 has no whole-number factors other than 1 and itself.

Examples

A prime number

17 is prime: no whole number between 2 and 16 divides evenly into it.

Not a prime number

18 is not prime: it divides evenly by 2, 3, 6 and 9, among others.

The only even prime

2 is prime: the only whole numbers that divide evenly into it are 1 and 2. Every even number above 2 is divisible by 2 and larger than 2, so it has a factor other than 1 and itself and is not prime.

A prime in the thousands

7919 is prime. No whole number below 89 divides evenly into it, and 89 × 89 = 7921 is already larger than 7919, so there is no larger factor left to find either.

Common uses

  • Generating test data for a programming exercise that needs a whole number known to be prime.
  • Checking a number quoted in a puzzle or a forum answer before you accept it.
  • Narrowing a list of candidates down to the primes before choosing one as a modulus in a cryptography exercise.

Things to keep in mind

  • 0, 1 and negative numbers are not prime — this is a definition, not an error, so the calculator simply answers "no" for them.
  • 2 is the only even prime number; every other even number has 2 as a factor.
  • Decimals are refused rather than rounded, because only whole numbers can be prime: 7.5 is not quietly turned into 7 or 8.
  • Whole numbers up to 1,000,000,000,000 are checked exactly. A larger number is refused, because a trial-division search up to the square root would begin to slow the page noticeably.
  • The result is a yes or a no rather than a number, so nothing is rounded: the check either holds exactly or the input is rejected.

Frequently asked questions

Is 1 a prime number?

No. By definition, a prime number must have exactly two whole-number factors: 1 and itself. 1 only has one factor (itself), so it is not prime.

What is the fastest way to check if a number is prime?

You only need to test whole-number divisors up to the square root of the number — if none of them divide evenly, none of the larger ones will either. This calculator uses exactly that method.

Why does the calculator refuse a decimal such as 7.5?

Primality is defined in terms of whole-number factors, so a decimal has no answer either way. Rather than round 7.5 to 7 or 8 and give a yes or no that does not describe the number you typed, the calculator asks for a whole number.

Why do prime numbers matter?

Every whole number greater than 1 is a product of primes, and the product is unique: 12 can be written as 3 × 4 or 6 × 2, but its prime factors are always 2 × 2 × 3. That is what makes it possible to decide whether a fraction can be simplified, since a fraction reduces exactly when its numerator and denominator share a factor. The Fraction Calculator carries out that reduction.

Background and method