OFFSET
3,1
COMMENTS
a(n) is even if n is odd and vice versa. It seems that all records are even.
n - 1 and n + 1 are twin primes if a(n) = 1.
n - 2 and n + 2 are cousin primes for n > 3 if a(n) = 2.
n - 3 and n + 3 are sexy primes if a(n) = A051700(n) = 3.
FORMULA
a(n) = max{n - prevprime(n), nextprime(n) - n}.
MATHEMATICA
Array[Max[#1 - #2, #3 - #1] & @@ Prepend[NextPrime[#, {-1, 1}], #] &, 105, 3] (* Michael De Vlieger, Mar 17 2021 *)
PROG
(Python)
from sympy import prevprime, nextprime
for n in range(3, 1001):
prevp = prevprime(n); nextp = nextprime(n)
print(max(n - prevp, nextp - n))
(PARI) for(n=3, 88, my(d1=n-precprime(n-1), d2=nextprime(n+1)-n); print1(max(d1, d2), ", ")) \\ Hugo Pfoertner, Mar 10 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Ya-Ping Lu, Feb 20 2021
STATUS
approved