%I #20 Jan 31 2015 11:25:36
%S 1,1,1,1,1,1,1,1,3,2,1,1,1,2,2,1,1,1,1,3,3,5,5,7,2,3,4,5,3,1,1,2,3,1,
%T 5,1,4,1,2,8,1,3,1,4,3,5,5,2,17,3,4,3,21,2,1,5,8,10,7,4,1,12,3,1,3,1,
%U 3,5,8,10,8,2,4,20,2,1,11,4,14,4,3,4,17,12,2,8,13,7,1,13,5,3,5,1,8,4,13,6,3,21,10,5,1,12,7,5,1,12,3,9,7
%N Least number k>0 such that at least one of (2^k-1)*2^n-1, (2^k-1)*2^n+1, (2^k+1)*2^n-1, or (2^k+1)*2^n+1 is a prime number.
%C More than 73% of a(n) are < n/10.
%C Conjecture: for n>1 a(n) is always < n.
%C Define partial sums S(N) = sum_{i=1..N} a(i) and T(N)=sum_{i=1..N} i = A000217(N). Then as N increases S(N)/T(n) tends to 0.078.
%H Pierre CAMI, <a href="/A210650/b210650.txt">Table of n, a(n) for n = 1..10000</a>
%p A210650 := proc(n)
%p for k from 1 do
%p if isprime((2^k-1)*2^n-1) then
%p return k;
%p elif isprime((2^k-1)*2^n+1) then
%p return k;
%p elif isprime((2^k+1)*2^n-1) then
%p return k;
%p elif isprime((2^k+1)*2^n+1) then
%p return k;
%p end if;
%p end do:
%p end proc: # _R. J. Mathar_, Apr 02 2012
%t lnk[n_]:=Module[{k=1,t=2^n},While[!AnyTrue[Flatten[{t(2^k-1)+{1,-1}, t(2^k+1)+ {1,-1}}],PrimeQ],k++];k]; Array[lnk, 120] (* The program uses the AnyTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Jan 31 2015 *)
%o PFGW64 and SCRIPTIFY from Primeform group
%o Command: PFGW64 -f in.txt
%o in.txt file :
%o SCRIPT
%o DIM nn,0
%o DIM kk
%o DIMS tt
%o OPENFILEOUT myfile,a(n).txt
%o LABEL loopn
%o SET nn,nn+1
%o IF nn>10000 THEN END
%o SET kk,0
%o LABEL loopk
%o SET kk,kk+1
%o IF kk>2*nn THEN GOTO loopn
%o SETS tt,%d,%d,%d,%d\,;nn;kk;-1;-1
%o PRP 2^nn*(2^kk-1)-1,tt
%o IF ISPRP THEN GOTO a
%o IF ISPRIME THEN GOTO a
%o SETS tt,%d,%d,%d,%d\,;nn;kk;-1;1
%o PRP 2^nn*(2^kk-1)+1,tt
%o IF ISPRP THEN GOTO a
%o IF ISPRIME THEN GOTO a
%o SETS tt,%d,%d,%d,%d\,;nn;kk;1;-1
%o PRP 2^nn*(2^kk+1)-1,tt
%o IF ISPRP THEN GOTO a
%o IF ISPRIME THEN GOTO a
%o SETS tt,%d,%d,%d,%d\,;nn;kk;1;1
%o PRP 2^nn*(2^kk+1)+1,tt
%o IF ISPRP THEN GOTO a
%o IF ISPRIME THEN GOTO a
%o GOTO loopk
%o LABEL a
%o WRITE myfile,tt
%o GOTO loopn
%K nonn
%O 1,9
%A _Pierre CAMI_, Mar 27 2012