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.

Original entry on oeis.org

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

Views

Author

Irina Gerasimova, Jan 27 2014

Keywords

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,...
		

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