Maths & numbers

Prime neighbors and gap calculator

Locate the prime immediately below the input and the prime immediately above it.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Locate the prime immediately below the input and the prime immediately above it.

THE FORMULAFind the closest strictly smaller and strictly larger primes

A worked example

The prime neighbors of 20 are 19 and 23, a gap of four.

Good to know

When the input is prime, the two neighbors exclude it.

Read the result

Locate the prime immediately below the input and the prime immediately above it.

The primary result is labeled “Distance between primes”. Keep the input definitions in view when comparing this result with another method.

Try a related calculation

When the input is prime, the two neighbors exclude it.

For a related exercise, try the greatest common divisor.

A few questions, answered

How can I check the default inputs by hand?

The prime neighbors of 20 are 19 and 23, a gap of four.

Which rule does this calculator apply?

Find the closest strictly smaller and strictly larger primes

Find your calculator

Start typing to explore the library.