OFFSET
1,1
COMMENTS
Numbers n such that a(n-1)=a(n+1)=n are A025584 (primes p such that p-2 is not a prime). - Rick L. Shepherd, Aug 23 2004
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
FORMULA
MAPLE
f:= proc(n) local j, k;
for k from 1 do
for j in [-1, 1] do
if isprime(k*n+j) then return k*n+j fi
od od
end proc:
map(f, [$1..100]); # Robert Israel, Nov 07 2019
MATHEMATICA
a[n_] := Module[{p}, For[p = 2, True, p = NextPrime[p], If[Divisible[p-1, n] || Divisible[p+1, n], Return[p]]]];
Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Feb 04 2023 *)
PROG
(PARI) a(n) = forprime(p=2, , if (!((p+1) % n) || !((p-1) % n), return (p))); \\ Michel Marcus, Aug 08 2014
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Amarnath Murthy, Apr 20 2004
EXTENSIONS
More terms from Rick L. Shepherd, Aug 23 2004
STATUS
approved