cp's OEIS Frontend

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.

A236513 The n-th prime with n 1-bits in its binary expansion.

This page as a plain text file.
%I A236513 #24 Sep 03 2021 01:50:30
%S A236513 2,5,13,53,79,373,379,983,1783,6007,7151,21503,31231,98207,129919,
%T A236513 259967,507839,1564159,1830911,4193263,8355583,25157567,33288191,
%U A236513 92274671,134180863,394264447,536838139,1072693243,2145382399,6442188791,8522825599,17179836413
%N A236513 The n-th prime with n 1-bits in its binary expansion.
%H A236513 Chai Wah Wu, <a href="/A236513/b236513.txt">Table of n, a(n) for n = 1..1014</a>
%e A236513 Primes p such that
%e A236513 A000120(p) = 1: 2;
%e A236513 A000120(p) = 2: 3, 5, 17, 257,...
%e A236513 A000120(p) = 3: 7, 11, 13, 19, 37, 41,...
%e A236513 A000120(p) = 4: 23, 29, 43, 53, 71, 83, 89,...
%e A236513 A000120(p) = 5: 31, 47, 59, 61, 79, 103, 107, 109,...
%e A236513 A000120(p) = 6: 311, 317, 347, 349, 359, 373,...
%t A236513 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 *)
%o A236513 (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
%o A236513 (Python)
%o A236513 from itertools import combinations
%o A236513 from sympy import isprime
%o A236513 def A236513(n):
%o A236513     l, k, c = n-1, 2**n, 0
%o A236513     while True:
%o A236513         for d in combinations(range(l-1,-1,-1),l-n+1):
%o A236513             m = k-1 - sum(2**(e) for e in d)
%o A236513             if isprime(m):
%o A236513                 c += 1
%o A236513                 if c == n:
%o A236513                     return m
%o A236513         l += 1
%o A236513         k *= 2 # _Chai Wah Wu_, Sep 02 2021
%Y A236513 Cf. A061712 (least prime having n ones in binary).
%K A236513 nonn,easy,base
%O A236513 1,1
%A A236513 _Irina Gerasimova_, Jan 27 2014
%E A236513 a(24)-a(32) from _Giovanni Resta_, Feb 04 2014