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-5 of 5 results.

A280999 Numbers with a prime number of 0's in their binary reflected Gray code representation.

Original entry on oeis.org

7, 8, 12, 14, 15, 16, 17, 19, 23, 24, 25, 27, 28, 29, 30, 33, 34, 35, 36, 38, 39, 40, 44, 46, 47, 49, 50, 51, 52, 54, 55, 57, 58, 59, 61, 63, 64, 66, 68, 69, 70, 72, 73, 75, 76, 77, 78, 80, 81, 83, 87, 88, 89, 91, 92, 93, 94, 96, 98, 100, 101, 102, 104, 105, 107
Offset: 1

Views

Author

Indranil Ghosh, Jan 12 2017

Keywords

Examples

			27 is in the sequence because the binary reflected Gray Code representation of 27 is 10110 which has 2 0's and 2 is prime.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[100], PrimeQ[DigitCount[BitXor[#, Floor[#/2]], 2, 0]] &] (* Amiram Eldar, May 01 2021 *)
  • PARI
    is(n)=isprime(logint(n,2)-hammingweight(bitxor(n, n>>1))+1) \\ Charles R Greathouse IV, Jan 13 2017

A144213 Primes with a prime number of 0's in their binary representations.

Original entry on oeis.org

17, 19, 37, 41, 43, 53, 71, 79, 83, 89, 101, 103, 107, 109, 113, 131, 137, 151, 157, 167, 173, 179, 181, 193, 199, 211, 227, 229, 233, 241, 257, 263, 269, 277, 281, 293, 311, 317, 337, 347, 349, 353, 359, 367, 373, 379, 389, 401, 431, 439, 443, 449, 461, 463
Offset: 1

Views

Author

Leroy Quet, Sep 14 2008

Keywords

Examples

			41, a prime, in binary is 101001. This has three 0's and 3 is prime, so 41 is in the sequence.
		

Crossrefs

Cf. A081092, A144214. Intersection of A000040 and A144754.

Programs

  • Maple
    A080791 := proc(n) local i,dgs ; dgs := convert(n,base,2) ; nops(dgs)-add(i,i=dgs) ; end: isA144213 := proc(n) local no0 ; no0 := A080791(n) ; if isprime(n) and isprime(no0) then true ; else false; fi; end: for n from 1 to 1200 do if isA144213(n) then printf("%d,",n) ; fi; od: # R. J. Mathar, Sep 17 2008
    # second Maple program:
    q:= n-> isprime(n) and isprime(add(1-i, i=Bits[Split](n))):
    select(q, [$1..500])[];  # Alois P. Heinz, Dec 27 2023
  • Mathematica
    nmax = 100;
    Select[Prime[Range[nmax]],
    PrimeQ[Total@Mod[1 + IntegerDigits[#, 2], 2]] &] (* Andres Cicuttin, Jul 08 2020 *)
    Select[Prime[Range[100]],PrimeQ[DigitCount[#,2,0]]&] (* Harvey P. Dale, Feb 03 2021 *)
  • Python
    from sympy import isprime
    def ok(n): return isprime(n.bit_length()-n.bit_count()) and isprime(n)
    print([k for k in range(464) if ok(k)]) # Michael S. Branicky, Dec 27 2023

Extensions

More terms from R. J. Mathar, Sep 17 2008

A144752 Positive integers whose binary representation is a palindrome and has a prime number of 0's.

Original entry on oeis.org

9, 17, 21, 45, 51, 65, 85, 93, 99, 107, 189, 219, 231, 257, 297, 325, 365, 381, 387, 427, 443, 455, 471, 765, 891, 951, 975, 1105, 1161, 1241, 1285, 1365, 1421, 1501, 1533, 1539, 1619, 1675, 1755, 1787, 1799, 1879, 1911, 1935, 1967, 3069, 3579, 3831, 3951
Offset: 1

Views

Author

Leroy Quet, Sep 20 2008

Keywords

Comments

Each term of this sequence is in both sequence A006995 and sequence A144754.

Examples

			17 in binary is 10001. This binary representation is a palindrome, it contains three 0's, and three is a prime. So 17 is a term.
		

Crossrefs

Programs

  • Python
    from sympy import isprime
    def ok(n): b = bin(n)[2:]; return b == b[::-1] and isprime(b.count('0'))
    print(list(filter(ok, range(4000)))) # Michael S. Branicky, Sep 17 2021
    
  • Python
    # faster for computing initial segment of sequence
    from sympy import isprime
    from itertools import product
    def ok2(bin_str): return isprime(bin_str.count("0"))
    def bin_pals(maxdigits):
        yield from "01"
        digits, midrange = 2, [[""], ["0", "1"]]
        for digits in range(2, maxdigits+1):
            for p in product("01", repeat=digits//2-1):
                left = "1"+"".join(p)
                for middle in midrange[digits%2]:
                    yield left + middle + left[::-1]
    def auptopow2(e): return [int(b, 2) for b in filter(ok2, bin_pals(e))]
    print(auptopow2(12)) # Michael S. Branicky, Sep 17 2021

Extensions

Extended by Ray Chandler, Nov 04 2008
Name edited by Michael S. Branicky, Sep 17 2021

A343258 Numbers whose binary representation has a prime number of zeros and a prime number of ones.

Original entry on oeis.org

9, 10, 12, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 65, 66, 68, 72, 79, 80, 87, 91, 93, 94, 96, 103, 107, 109, 110, 115, 117, 118, 121, 122, 124, 131, 133, 134, 137, 138, 140, 143, 145, 146, 148, 151, 152, 155, 157, 158
Offset: 1

Views

Author

Jean-Jacques Vaudroz, Apr 09 2021

Keywords

Comments

Terms of 4, 5 and 6 total bits (9 through 56) are the same as A089648.

Crossrefs

Intersection of A052294 and A144754.
Cf. A089648.

Programs

  • Maple
    q:= n->(l->(t->andmap(isprime, [t, nops(l)-t]))(add(i, i=l)))(Bits[Split](n)):
    select(q, [$1..200])[];  # Alois P. Heinz, Apr 11 2021
  • Mathematica
    Select[Range[160], And @@ PrimeQ[DigitCount[#, 2]] &] (* Amiram Eldar, Apr 09 2021 *)
  • PARI
    isa(n)= isprime(hammingweight(n));
    isb(n)= isprime(#binary(n) - hammingweight(n));
    isok(n) = isa(n) && isb(n);
    
  • Python
    from sympy import isprime
    def ok(n): b = bin(n)[2:]; return all(isprime(b.count(d)) for d in "01")
    print(list(filter(ok, range(159)))) # Michael S. Branicky, Sep 10 2021

A380786 Numbers with a prime number of bits, prime number of ones, and prime number of zeros in their binary representation.

Original entry on oeis.org

17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 65, 66, 68, 72, 79, 80, 87, 91, 93, 94, 96, 103, 107, 109, 110, 115, 117, 118, 121, 122, 124, 4097, 4098, 4100, 4104, 4112, 4128, 4160, 4224, 4352, 4608, 5119, 5120, 5631, 5887, 6015, 6079, 6111, 6127, 6135, 6139, 6141, 6142, 6144, 6655, 6911
Offset: 1

Views

Author

Marc Morgenegg, Feb 03 2025

Keywords

Comments

Each term has either two zeros or two ones in its binary representation. And so the total number of bits of each term is the larger prime of a twin prime pair.

Examples

			a(1) = 17 = 10001_2. Number of bits is 5, number of ones is 2, number of zeros is 3. {2,3,5} are all primes.
		

Crossrefs

Intersection of A052294, A144754, and A380788.
Subsequence of primes gives A272478.
Subsequence of A343258.
Cf. A006512 (bitlengths of terms).

Programs

  • Mathematica
    Select[Range[2^13], AllTrue[{#1, #2, #1 - #2} & @@ {IntegerLength[#,2], DigitCount[#, 2, 1]}, PrimeQ] & ] (* Michael De Vlieger, Feb 03 2025 *)
  • PARI
    isok(k) = my(h=hammingweight(k), b=#binary(k)); isprime(h) && isprime(b) && isprime(b-h); \\ Michel Marcus, Feb 07 2025
  • Python
    from sympy import isprime
    def ok(n): return isprime(L:=n.bit_length()) and isprime(O:=n.bit_count()) and isprime(L-O)
    print([k for k in range(7160) if ok(k)]) # Michael S. Branicky, Feb 03 2025
    
  • Python
    from sympy import isprime, nextprime, sieve
    from itertools import combinations, count, islice
    def agen(): # generator of terms
        p = 5
        while True:
            passed = set()
            if isprime(p-2):
                for q in [2, p-2]:
                    for locs in combinations(range(1, p), q-1):
                        w = ["1"] + ["0"]*(p-1)
                        for i in locs: w[i] = "1"
                        passed.add(int("".join(w), 2))
            yield from sorted(passed)
            p = nextprime(p)
            print(len(passed), p)
    print(list(islice(agen(), 61))) # Michael S. Branicky, Feb 03 2025
    
Showing 1-5 of 5 results.