OFFSET
0,6
COMMENTS
a(n) = 1 iff n is in A006254. - Robert Israel, Sep 02 2016
For n > 1, a(n) = 0 iff 2n+1 is de Polignac number, A006285. - Thomas Ordowski, Apr 13 2017
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
EXAMPLE
a(14) = 4 because (2*14 + 1) - 2^k is composite for k = 1, 2, 3 and prime for k = 4.
MAPLE
f:= proc(n) local k;
for k from 1 do
if 2*n < 2^k then return 0
elif isprime(2*n+1-2^k) then return k
fi
od
end proc:
map(f, [$0..100]); # Robert Israel, Sep 02 2016
MATHEMATICA
Table[If[n <= 2, 0, k = 1; While[! PrimeQ[2 n + 1 - 2^k], k++]; k], {n, 0, 120}] (* Michael De Vlieger, Sep 03 2016 *)
PROG
(Magma) lst:=[]; for n in [1..173 by 2] do k:=0; c:=k; repeat k+:=1; c+:=1; a:=n-2^k; until a lt 1 or IsPrime(a); if a lt 1 then Append(~lst, 0); else Append(~lst, c); end if; end for; lst;
(PARI) a(n) = my(k=1); while(2^k < 2*n+1, if(ispseudoprime((2*n+1)-2^k), return(k)); k++); return(0) \\ Felix Fröhlich, Sep 02 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Arkadiusz Wesolowski, Sep 02 2016
STATUS
approved