login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 1

%I #21 Feb 25 2018 20:10:51

%S 2,0,37,139,541,2141,8287,33119,131519,525247,2098687,8391679,

%T 33561599,134242271,536895487,2147548159,8590061567,34360196863,

%U 137439412223,549756861439,2199026663423,8796097216447,35184380411903

%N 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 Robert Israel, <a href="/A145576/b145576.txt">Table of n, a(n) for n = 1..1000</a>

%e 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 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 # Alternative:

%p F:= proc(n) local c,x;

%p c:= [$n+1..2*n-2];

%p do

%p x:= 2^(2*n-1)+1+add(2^(2*n-1-c[i]),i=1..n-2);

%p if isprime(x) then return x fi;

%p c:= combinat:-prevcomb(c, 2*n-2)

%p od

%p end proc:

%p 2, 0, seq(F(n),n=3..30); # _Robert Israel_, Sep 24 2017

%t 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 Cf. A066195, A061712.

%K base,nonn

%O 1,1

%A _Leroy Quet_, Oct 13 2008

%E Extended by _R. J. Mathar_ and _Ray Chandler_, Oct 14 2008

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 13:30 EDT 2024. Contains 371957 sequences. (Running on oeis4.)