TOPICS
Search

Nearest Prime


The nearest prime to a nonnegative integer n is the prime minimizing its distance from n. Assigning ties to the smaller prime, the values for n=0, 1, 2, ... are 2, 2, 2, 3, 3, 5, 5, 7, 7, 7, 11, 11, 11, 13, ... (OEIS A051697). If ties are instead assigned to the larger prime, the corresponding sequence is instead 2, 2, 2, 3, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, ... (OEIS A077018), which is identical except that one of the 3s is omitted.


See also

Prime Distance, Prime Gaps

Explore with Wolfram|Alpha

References

Sloane, N. J. A. Sequences A051697 and A077018 in "The On-Line Encyclopedia of Integer Sequences."

Referenced on Wolfram|Alpha

Nearest Prime

Cite this as:

Weisstein, Eric W. "Nearest Prime." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/NearestPrime.html

Subject classifications