The nearest prime to a nonnegative integer is the prime
minimizing its distance from
. Assigning ties to the smaller prime,
the values for
,
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.
Nearest Prime
See also
Prime Distance, Prime GapsExplore 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 PrimeCite this as:
Weisstein, Eric W. "Nearest Prime." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/NearestPrime.html