login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A093868
Smallest prime that differs from a multiple of n by unity.
5
2, 3, 2, 3, 11, 5, 13, 7, 17, 11, 23, 11, 53, 13, 29, 17, 67, 17, 37, 19, 41, 23, 47, 23, 101, 53, 53, 29, 59, 29, 61, 31, 67, 67, 71, 37, 73, 37, 79, 41, 83, 41, 173, 43, 89, 47, 281, 47, 97, 101, 101, 53, 107, 53, 109, 113, 113, 59, 353, 59, 367, 61, 127, 127, 131, 67, 269
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
FORMULA
a(n) = min(A034694(n), A038700(n)) for all n >= 1. - Rick L. Shepherd, Aug 23 2004
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
Cf. A093869.
Cf. A034694 (Smallest prime == 1 (mod n)), A038700 (Smallest prime == -1 (mod n)).
Sequence in context: A264766 A251090 A078331 * A194603 A183465 A223168
KEYWORD
nonn,look
AUTHOR
Amarnath Murthy, Apr 20 2004
EXTENSIONS
More terms from Rick L. Shepherd, Aug 23 2004
STATUS
approved