%I #17 Feb 04 2023 04:05:14
%S 2,3,2,3,11,5,13,7,17,11,23,11,53,13,29,17,67,17,37,19,41,23,47,23,
%T 101,53,53,29,59,29,61,31,67,67,71,37,73,37,79,41,83,41,173,43,89,47,
%U 281,47,97,101,101,53,107,53,109,113,113,59,353,59,367,61,127,127,131,67,269
%N Smallest prime that differs from a multiple of n by unity.
%C 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
%H Robert Israel, <a href="/A093868/b093868.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n) = min(A034694(n), A038700(n)) for all n >= 1. - _Rick L. Shepherd_, Aug 23 2004
%p f:= proc(n) local j,k;
%p for k from 1 do
%p for j in [-1,1] do
%p if isprime(k*n+j) then return k*n+j fi
%p od od
%p end proc:
%p map(f, [$1..100]); # _Robert Israel_, Nov 07 2019
%t a[n_] := Module[{p}, For[p = 2, True, p = NextPrime[p], If[Divisible[p-1, n] || Divisible[p+1, n], Return[p]]]];
%t Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, Feb 04 2023 *)
%o (PARI) a(n) = forprime(p=2, , if (!((p+1) % n) || !((p-1) % n), return (p))); \\ _Michel Marcus_, Aug 08 2014
%Y Cf. A093869.
%Y Cf. A034694 (Smallest prime == 1 (mod n)), A038700 (Smallest prime == -1 (mod n)).
%K nonn,look
%O 1,1
%A _Amarnath Murthy_, Apr 20 2004
%E More terms from _Rick L. Shepherd_, Aug 23 2004