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”).

If n is even, a(n) = smallest prime == 1 (mod n), If n is odd, a(n) = smallest prime == -1 (mod n).
2

%I #9 Dec 09 2020 19:59:28

%S 2,3,2,5,19,7,13,17,17,11,43,13,103,29,29,17,67,19,37,41,41,23,137,73,

%T 149,53,53,29,173,31,61,97,131,103,139,37,73,191,233,41,163,43,257,89,

%U 89,47,281,97,97,101,101,53,211,109,109,113,113,59,353,61,487,311,251

%N If n is even, a(n) = smallest prime == 1 (mod n), If n is odd, a(n) = smallest prime == -1 (mod n).

%H Robert Israel, <a href="/A086507/b086507.txt">Table of n, a(n) for n = 1..10000</a>

%p f:= proc(n) local x;

%p if n::even then x:= 1 else x:= -1; fi;

%p do

%p x:= x+n;

%p if isprime(x) then return x fi

%p od

%p end proc:

%p map(f, [$1..100]); # _Robert Israel_, Dec 09 2020

%Y Cf. A034694, A038700, A086508.

%K nonn

%O 1,1

%A _Amarnath Murthy_, Jul 29 2003

%E More terms from _David Wasserman_, Mar 09 2005