login
Least k such that 2*n*k + 1 is a prime.
20

%I #52 Apr 23 2023 15:27:51

%S 1,1,1,2,1,1,2,1,1,2,1,3,2,1,1,3,3,1,5,1,1,2,1,2,2,1,2,2,1,1,5,3,1,2,

%T 1,1,2,3,1,3,1,4,2,1,2,3,3,1,2,1,1,3,1,1,3,1,2,2,6,2,3,3,1,2,1,3,2,1,

%U 1,2,4,3,2,1,1,3,3,1,2,4,1,5,1,2,6,1,2,2,1,1,3,7,2,5,1,1,2,1,1

%N Least k such that 2*n*k + 1 is a prime.

%C Is the sequence bounded? - _Zak Seidov_, Mar 25 2014

%C Answer: No, for any given N a number n such that a(n) > N can be constructed by the Chinese Remainder Theorem, see A239727. - _Charles R Greathouse IV_, Mar 25 2014

%C a(n) = 1 for n in A005097. - _Robert Israel_, Oct 26 2016

%H Zak Seidov, <a href="/A016014/b016014.txt">Table of n, a(n) for n = 1..10000</a>

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

%p for k from 1 do if isprime(2*n*k+1) then return k fi od

%p end proc:

%p map(f, [$1..100]); # _Robert Israel_, Oct 26 2016

%t Do[k = 1; cp = n*k + 1; While[ ! PrimeQ[cp], k++; cp = n*k + 1]; Print[k], {n, 2, 400, 2}] (* _Lei Zhou_, Feb 23 2005 *)

%t lk[n_]:=Module[{k=1},While[!PrimeQ[2n k+1],k++];k]; Array[lk,100] (* _Harvey P. Dale_, Apr 23 2023 *)

%o (PARI) a(n)=my(k); while(!isprime(2*n*(k++)+1),);k \\ _Charles R Greathouse IV_, Mar 25 2014

%o (Python)

%o from sympy import isprime

%o def a(n):

%o k = 1

%o while not isprime(2*n*k + 1): k += 1

%o return k

%o print([a(n) for n in range(1, 100)]) # _Michael S. Branicky_, Mar 28 2022

%Y Cf. A005097, A103961.

%Y A070846 contains the corresponding primes.

%Y Records are in A239746 with indices in A239727.

%K nonn

%O 1,4

%A _Robert G. Wilson v_