OFFSET
1,1
COMMENTS
It is perhaps surprising that the values in this sequence are so small. For n < 8000 the largest value of a(n) is 20, which occurs for n = 4928. Also for n < 8000, a(n) is 2 on 2449 occasions.
a(n)=2 if and only if A014574(n)+1 is in A038869 or A014574(n)-1 is in A045536. - Robert Israel, Jul 17 2019
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
72*5 = 360, which is adjacent to the prime 359, so a(8) = 5.
MAPLE
P:= {seq(ithprime(i), i=1..10^4)}:
A014574:= sort(convert(map(t -> t+1, P intersect map(`-`, P, 2)), list)):
f:= proc(m) local k;
for k from 2 do
if isprime(k*m-1) or isprime(k*m+1) then return k fi
od
end proc:
map(f, A014574); # Robert Israel, Jul 17 2019
MATHEMATICA
primeNearQ[n_] := AnyTrue[{-1, 1} + n, PrimeQ]; twinMidQ[n_] := AllTrue[{-1, 1} + n, PrimeQ]; f[n_] := Module[{k = 2}, While[! primeNearQ[k*n], k++]; k]; f /@ Select[Range[10^4], twinMidQ] (* Amiram Eldar, Jul 05 2019 *)
PROG
(PARI) isok2(n) = isprime(n-1) && isprime(n+1);
k(n) = my(k=2); while (! (isprime(n*k-1) || isprime(n*k+1)), k++); k;
lista(nn) = for (n=1, nn, if (isok2(n), print1(k(n), ", "))); \\ Michel Marcus, May 01 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Dmitry Kamenetsky, May 01 2019
STATUS
approved