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.

Showing 1-3 of 3 results.

A120533 Primes having a prime number of digits.

Original entry on oeis.org

11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283
Offset: 1

Views

Author

Cino Hilliard, Aug 06 2006

Keywords

Comments

Before the 20th century, this sequence would have contained the numbers 1,2,3,5,7; see A008578.
There are a total of 8527 terms for primes with 2, 3, or 5 digits, and a total of 594608 terms if primes with 7 digits are also included. - Harvey P. Dale, Nov 02 2020

Examples

			10007 is a 5-digit prime and so belongs to the sequence.
		

Crossrefs

Programs

  • Mathematica
    Table[Prime[Range[PrimePi[10^(p-1)]+1,PrimePi[10^p]]],{p,Prime[Range[ 3]]}]//Flatten (* Harvey P. Dale, Nov 02 2020 *)
  • PARI
    g(n) = forprime(x=11,n,if(isprime(length(Str(x))),print1(x",")))
    
  • PARI
    forprime(p=2,5,forprime(q=10^(p-1),10^p,print1(q", "))) \\ Charles R Greathouse IV, Oct 04 2011
    
  • Python
    from itertools import islice
    from sympy import isprime, nextprime
    def agen(): # generator of terms
        d = 2
        while True:
            yield from (i for i in range(10**(d-1)+1, 10**d, 2) if isprime(i))
            d = nextprime(d)
    print(list(islice(agen(), 57))) # Michael S. Branicky, Dec 27 2023
    
  • Python
    from sympy import primepi, primerange
    def A272441(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            kmin = kmax >> 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return n+x-sum(primepi(min(x,(1<Chai Wah Wu, Feb 03 2025

Extensions

Edited by N. J. A. Sloane at the suggestion of Andrew S. Plewe, May 21 2007

A272478 Primes with a prime number of binary digits, and with a prime number of 1's and a prime number of 0's.

Original entry on oeis.org

17, 19, 79, 103, 107, 109, 5119, 6079, 6911, 7039, 7103, 7151, 7159, 7919, 7927, 7933, 8059, 8111, 8123, 8167, 8171, 8179, 442367, 458239, 458719, 458747, 487423, 491503, 499711, 507839, 507901, 515839, 516091, 520063, 523007, 523261, 523519, 523759, 523771, 523903, 524219, 524221, 524269
Offset: 1

Views

Author

Andres Cicuttin, May 01 2016

Keywords

Comments

If the sum of primes p and q is a prime r, then one of p and q must be 2. - N. J. A. Sloane, May 01 2016

Examples

			a(3) = 79, its binary representation is 1001111 with (prime) 7 digits, (prime) 5 1's and (prime) 2 0's.
		

Crossrefs

Cf. A006512 (bitlengths of terms).

Programs

  • Mathematica
    Select[Table[Prime[j],{j,1,120000}],PrimeQ[Total@IntegerDigits[#,2]]&&PrimeQ[Length@IntegerDigits[#,2]]&&PrimeQ[(Length@IntegerDigits[#,2]-Total@IntegerDigits[#,2])]&]
    Select[Prime@ Range[10^5], And[PrimeQ@ Total@ #, PrimeQ@ First@ #, PrimeQ@ Last@ #] &@ DigitCount[#, 2] &] (* Michael De Vlieger, May 01 2016 *)
  • PARI
    isok(n) = isprime(n) && isprime(#binary(n)) && isprime(hammingweight(n)) && isprime(#binary(n) - hammingweight(n)); \\ Michel Marcus, May 01 2016
    
  • Python
    from sympy import isprime, nextprime
    from itertools import combinations, islice
    def agen(): # generator of terms
        p = 2
        while True:
            p = nextprime(p)
            if not isprime(p+2): continue
            if isprime(t:=(1<<(p+1))+1): yield t
            b = (1<<(p+2))-1
            for i, j in combinations(range(p), 2):
                if isprime(t:=b-(1<<(p-i))-(1<<(p-j))):
                    yield t
    print(list(islice(agen(), 43))) # Michael S. Branicky, Dec 27 2023

A380788 Numbers with a prime number of binary digits.

Original entry on oeis.org

2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106
Offset: 1

Views

Author

Michael S. Branicky, Feb 03 2025

Keywords

Examples

			4 is a term since its binary representation has 3 bits, a prime.
64 is a term since its binary representation has 7 bits, a prime.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[200], PrimeQ[BitLength[#]] &] (* Paolo Xausa, Feb 03 2025 *)
  • Python
    from sympy import isprime
    def ok(n): return isprime(n.bit_length())
    print([k for k in range(150) if ok(k)])
    
  • Python
    # faster for initial segment of sequence
    from itertools import islice
    from sympy import isprime, nextprime
    def agen(): # generator of terms
        d = 2
        while True:
            yield from (i for i in range(2**(d-1), 2**d))
            d = nextprime(d)
    print(list(islice(agen(), 65)))
    
  • Python
    from sympy import primerange
    def A380788(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            kmin = kmax >> 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return n+x-sum(min(x,(1<Chai Wah Wu, Feb 03 2025
Showing 1-3 of 3 results.