This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A145576 #21 Feb 25 2018 20:10:51 %S A145576 2,0,37,139,541,2141,8287,33119,131519,525247,2098687,8391679, %T A145576 33561599,134242271,536895487,2147548159,8590061567,34360196863, %U A145576 137439412223,549756861439,2199026663423,8796097216447,35184380411903 %N A145576 a(n) is the smallest prime with both exactly an n number of 0's and exactly an n number of 1's in its binary representation. a(n) = 0 if no such prime exists. %H A145576 Robert Israel, <a href="/A145576/b145576.txt">Table of n, a(n) for n = 1..1000</a> %e A145576 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 %p A145576 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 %p A145576 # Alternative: %p A145576 F:= proc(n) local c,x; %p A145576 c:= [$n+1..2*n-2]; %p A145576 do %p A145576 x:= 2^(2*n-1)+1+add(2^(2*n-1-c[i]),i=1..n-2); %p A145576 if isprime(x) then return x fi; %p A145576 c:= combinat:-prevcomb(c, 2*n-2) %p A145576 od %p A145576 end proc: %p A145576 2, 0, seq(F(n),n=3..30); # _Robert Israel_, Sep 24 2017 %t A145576 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 *) %Y A145576 Cf. A066195, A061712. %K A145576 base,nonn %O A145576 1,1 %A A145576 _Leroy Quet_, Oct 13 2008 %E A145576 Extended by _R. J. Mathar_ and _Ray Chandler_, Oct 14 2008