login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A236513
The n-th prime with n 1-bits in its binary expansion.
2
2, 5, 13, 53, 79, 373, 379, 983, 1783, 6007, 7151, 21503, 31231, 98207, 129919, 259967, 507839, 1564159, 1830911, 4193263, 8355583, 25157567, 33288191, 92274671, 134180863, 394264447, 536838139, 1072693243, 2145382399, 6442188791, 8522825599, 17179836413
OFFSET
1,1
EXAMPLE
Primes p such that
A000120(p) = 1: 2;
A000120(p) = 2: 3, 5, 17, 257,...
A000120(p) = 3: 7, 11, 13, 19, 37, 41,...
A000120(p) = 4: 23, 29, 43, 53, 71, 83, 89,...
A000120(p) = 5: 31, 47, 59, 61, 79, 103, 107, 109,...
A000120(p) = 6: 311, 317, 347, 349, 359, 373,...
MATHEMATICA
nn = 20; t = Table[-n + 1, {n, nn}]; p = 1; While[Min[t] <= 0, p = NextPrime[p]; b = Total[IntegerDigits[p, 2]]; If[b <= nn, If[t[[b]] < 0, t[[b]]++, If[t[[b]] == 0, t[[b]] = p]]]]; t (* T. D. Noe, Jan 27 2014 *)
PROG
(PARI) lista(nn) = {prm = primes(5000000); for (n = 1, nn, ltp = select(p->hammingweight(p)== n, prm); print1(ltp[n], ", "); ); } \\ Michel Marcus, Jan 27 2014
(Python)
from itertools import combinations
from sympy import isprime
def A236513(n):
l, k, c = n-1, 2**n, 0
while True:
for d in combinations(range(l-1, -1, -1), l-n+1):
m = k-1 - sum(2**(e) for e in d)
if isprime(m):
c += 1
if c == n:
return m
l += 1
k *= 2 # Chai Wah Wu, Sep 02 2021
CROSSREFS
Cf. A061712 (least prime having n ones in binary).
Sequence in context: A353719 A353722 A105905 * A214853 A075738 A076999
KEYWORD
nonn,easy,base
AUTHOR
Irina Gerasimova, Jan 27 2014
EXTENSIONS
a(24)-a(32) from Giovanni Resta, Feb 04 2014
STATUS
approved