How this calculation works
Locate the prime immediately below the input and the prime immediately above it.
Find the closest strictly smaller and strictly larger primesA 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.
Reference: NIST DLMF, Functions of Number Theory (opens in a new tab) ↗
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