OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..1000
EXAMPLE
a(3) = 37 = 100101 (base 2) is the smallest prime with three 0's and three 1's in its binary representation. - R. J. Mathar, Oct 14 2008
MAPLE
A000120 := proc(n) local d; add(d, d=convert(n, base, 2)) ; end: A080791 := proc(n) local d, dgs; dgs := convert(n, base, 2) ; nops(dgs)-add(d, d=dgs) ; end: A070939 := proc(n) max(1, ilog2(n)+1) ; end: A145576 := proc(n) local p, pbin; p := nextprime(2^(2*n-1)-1); while true do pbin := A070939(p) ; if pbin > 2*n then RETURN(0) ; elif pbin = 2*n then if A000120(p) = n and A080791(p) = n then RETURN(p) ; fi; fi; p := nextprime(p) ; od: end: seq(A145576(n), n=1..30) ; # R. J. Mathar, Oct 14 2008
# Alternative:
F:= proc(n) local c, x;
c:= [$n+1..2*n-2];
do
x:= 2^(2*n-1)+1+add(2^(2*n-1-c[i]), i=1..n-2);
if isprime(x) then return x fi;
c:= combinat:-prevcomb(c, 2*n-2)
od
end proc:
2, 0, seq(F(n), n=3..30); # Robert Israel, Sep 24 2017
MATHEMATICA
Table[SelectFirst[Prime@ Apply[Range, PrimePi@{2^(2 (n - 1)) + 1, 2^(2 n) - 1}], Union@ DigitCount[#, 2] == {n} &] /. k_ /; MissingQ@ k -> 0, {n, 12}] (* Michael De Vlieger, Sep 24 2017 *)
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Leroy Quet, Oct 13 2008
EXTENSIONS
Extended by R. J. Mathar and Ray Chandler, Oct 14 2008
STATUS
approved