A236513 The n-th prime with n 1-bits in its binary expansion.
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
Examples
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,...
Links
- Chai Wah Wu, Table of n, a(n) for n = 1..1014
Crossrefs
Cf. A061712 (least prime having n ones in binary).
Programs
-
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 *)
-
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
Extensions
a(24)-a(32) from Giovanni Resta, Feb 04 2014