Prime Number Calculator

Check if a number is prime. The calculator also shows its prime factors, and the nearest prime numbers above and below it.

How it is calculated

Numbers below 2 are not prime by definition.

The number is tested for divisibility by 2, then by odd numbers only.

Testing stops at the square root, because any factor above it must pair with one below it — so if none were found by then, none exist.

Formula

Prime: A whole number above 1 with exactly two factors

Test: Check divisors up to √n only

Worked example

Checking whether 97 is prime.

Number: 97

√97 is about 9.8, so only divisors up to 9 need testing

97 is not divisible by 2, 3, 5 or 7

No factors found, so 97 has only 1 and itself

Answer: 97 is prime

Frequently asked questions

Why is 1 not a prime number?

A prime number must have exactly two different factors. The number 1 has only one factor — itself. Leaving 1 out also keeps prime factorisation working correctly, since you could otherwise multiply by 1 forever.

Is 2 really prime?

Yes, and it is the only even prime number. Every other even number can be divided by 2, so it has at least three factors.

Why only check up to the square root?

Factors come in pairs that multiply together to give the number. If one factor in a pair is bigger than the square root, the other one must be smaller. So if nothing below the square root divides evenly, nothing above it will either.