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.

Previous Showing 11-20 of 20 results.

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

Original entry on oeis.org

3, 5, 7, 9, 17, 21, 31, 33, 65, 73, 93, 107, 127, 129, 257, 273, 313, 341, 381, 403, 443, 471, 513, 1025, 1057, 1137, 1193, 1273, 1317, 1397, 1453, 1571, 1651, 1707, 1831, 2047, 2049, 4097, 4161, 4321, 4433, 4593, 4681, 4841, 4953, 5189, 5349, 5461, 5709
Offset: 1

Views

Author

Leroy Quet, Sep 20 2008

Keywords

Comments

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

Examples

			21 in binary is 10101. This binary representation is a palindrome, it contains three 1's, and three is a prime. So 21 is a term.
		

Crossrefs

Programs

  • Mathematica
    okQ[n_] := Module[{idn2 = IntegerDigits[n, 2]}, (idn2 == Reverse[idn2]) && PrimeQ[First[DigitCount[n, 2]]]];Select[Range[10000], okQ] (* Harvey P. Dale, Sep 23 2008 *)
  • Python
    from sympy import isprime
    def ok(n): b = bin(n)[2:]; return b == b[::-1] and isprime(b.count("1"))
    print(list(filter(ok, range(5710)))) # 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("1"))
    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(13)) # Michael S. Branicky, Sep 17 2021

Extensions

More terms from Harvey P. Dale, Sep 23 2008
Name edited by Michael S. Branicky, Sep 17 2021

A262481 Numbers m having in binary representation exactly lpf(m) ones, where lpf = least prime factor = A020639; a(1) = 1.

Original entry on oeis.org

1, 6, 10, 12, 18, 20, 21, 24, 34, 36, 40, 48, 55, 66, 68, 69, 72, 80, 81, 96, 115, 130, 132, 136, 144, 155, 160, 185, 192, 205, 258, 260, 261, 264, 272, 273, 288, 295, 320, 321, 355, 384, 395, 425, 514, 516, 520, 528, 535, 544, 565, 576, 595, 623, 625, 637
Offset: 1

Views

Author

Reinhard Zumkeller, Sep 24 2015

Keywords

Examples

			.   n | a(n) | A007088(a(n)) | factorization
. ----+------+---------------+--------------
.   1 |    1 |            1  |   1
.   2 |    6 |          110  |   2 * 3
.   3 |   10 |         1010  |   2 * 5
.   4 |   12 |         1100  |   2^2 * 3
.   5 |   18 |        10010  |   2 * 3^2
.   6 |   20 |        10100  |   2^2 * 5
.   7 |   21 |        10101  |   3 * 7
.   8 |   24 |        11000  |   2^3 * 3
.   9 |   34 |       100010  |   2 * 17
.  10 |   36 |       100100  |   2^2 * 3^2
.  11 |   40 |       101000  |   2^3 * 5
.  12 |   48 |       110000  |   2^4 * 3
.  13 |   55 |       110111  |   5 * 11
.  14 |   66 |      1000010  |   2 * 3 * 11
.  15 |   68 |      1000100  |   2^2 * 17
.  16 |   69 |      1000101  |   3 * 23
.  17 |   72 |      1001000  |   2^3 * 3^2
.  18 |   80 |      1010000  |   2^4 * 5
.  19 |   81 |      1010001  |   3^4
.  20 |   96 |      1100000  |   2^5 * 3
.  21 |  115 |      1110011  |   5 * 23
.  22 |  130 |     10000010  |   2 * 5 * 13
.  23 |  132 |     10000100  |   2^2 * 3 * 11
.  24 |  136 |     10001000  |   2^3 * 17
.  25 |  144 |     10010000  |   2^4 * 3^2  .
		

Crossrefs

Subsequence of A052294.

Programs

  • Haskell
    a262481 n = a262481_list !! (n-1)
    a262481_list = filter (\x -> a000120 x == a020639 x) [1..]
    
  • Mathematica
    Select[Range[640], FactorInteger[#][[1, 1]] == DigitCount[#, 2, 1] &] (* Amiram Eldar, Jul 24 2023 *)
  • PARI
    isok(n) = (n==1) || (hammingweight(n) == factor(n)[1,1]); \\ Michel Marcus, Sep 29 2015

Formula

A000120(a(n)) = A020639(a(n)).

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

A317294 Numbers with a noncomposite number of 1's in their binary expansion.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 44, 47, 48, 49, 50, 52, 55, 56, 59, 61, 62, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 76, 79, 80, 81, 82, 84, 87, 88, 91, 93, 94, 96, 97, 98, 100
Offset: 1

Views

Author

Omar E. Pol, Aug 10 2018

Keywords

Comments

Union of powers of 2 and pernicious numbers.
All powers of 2 are in the sequence because the binary expansion of a power of 2 contains only one digit "1" and 1 is a noncomposite number (A008578).
If k is in the sequence then so is 2*k. - David A. Corneth, Aug 10 2018

Examples

			8 is in the sequence because the binary expansion of 8 is 1000 and 1000 has one 1, and 1 is a noncomposite number (A008578).
26 is in the sequence because the binary expansion of 26 is 11010 and 11010 has three 1's, and 3 is a noncomposite number.
		

Crossrefs

Union of A000079 and A052294.
The complement is A317295.
All terms of A000051 are in this sequence.

Programs

  • Maple
    filter:= proc(n) local w;
      w:= convert(convert(n,base,2),`+`);
      w=1 or isprime(w)
    end proc:
    select(filter, [$1..1000]); # Robert Israel, Aug 15 2018
  • Mathematica
    Select[Range[100], !CompositeQ[DigitCount[#, 2, 1]] &] (* Amiram Eldar, Jul 23 2023 *)
  • PARI
    is(n) = my(h=hammingweight(n)); ispseudoprime(h) || h==1 \\ Felix Fröhlich, Aug 10 2018

A317295 Numbers with a composite number of 1's in their binary expansion.

Original entry on oeis.org

15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 63, 71, 75, 77, 78, 83, 85, 86, 89, 90, 92, 95, 99, 101, 102, 105, 106, 108, 111, 113, 114, 116, 119, 120, 123, 125, 126, 135, 139, 141, 142, 147, 149, 150, 153, 154, 156, 159, 163, 165, 166, 169, 170, 172, 175, 177, 178, 180, 183, 184, 187, 189, 190
Offset: 1

Views

Author

Omar E. Pol, Aug 10 2018

Keywords

Comments

By definition no power of 2 is in the sequence.

Examples

			23 is in the sequence because the binary expansion of 23 is 10111 and 10111 has four 1's, and 4 is a composite number (A002808).
		

Crossrefs

Programs

  • Mathematica
    Select[Range[200], CompositeQ[DigitCount[#, 2, 1]] &] (* Amiram Eldar, Jul 23 2023 *)
  • PARI
    isok(n) = my(w = hammingweight(n)); (w != 1) && !isprime(w); \\ Michel Marcus, Aug 15 2018
    
  • Python
    from sympy import isprime; isok = lambda n: n & (n-1) and not isprime(bin(n).count('1')) # David Radcliffe, Aug 15 2018

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

A355017 a(n) is the number of bases in 2..n in which the sum of the digits of n is prime.

Original entry on oeis.org

0, 1, 1, 3, 4, 4, 3, 5, 6, 7, 7, 8, 7, 8, 5, 11, 9, 10, 8, 13, 8, 12, 9, 13, 11, 12, 10, 15, 11, 16, 10, 17, 10, 20, 12, 20, 14, 18, 13, 21, 13, 22, 13, 20, 14, 25, 14, 22, 18, 22, 15, 26, 12, 29, 17, 25, 15, 27, 15, 30, 19, 26, 14, 32, 17, 33, 19, 27, 19, 31, 18, 34, 19, 29, 19, 37, 16, 33, 21, 30, 24, 39, 20, 38
Offset: 2

Views

Author

Samuel Harkness, Jun 15 2022

Keywords

Comments

The graph of (n,a(n)) shows an interesting structure, somewhat resembling a comet with four tails. Starting at the bottom tail and going upwards:
Observations:
The bottom "tail" contains all n with both 2 and 3 as prime factors, i.e., numbers n in A008588 (1/6 of all n).
The second "tail" contains all n with 2 as a prime factor but not 3, i.e., numbers n in A047235 (1/3 of all n).
The third "tail" contains all n with 3 as a prime factor but 2, i.e., numbers n in A016945 (1/6 of all n).
The top "tail" contains all n with neither 2 nor 3 as a prime factor, i.e., numbers n in A007310 (1/3 of all n).
The bottom of each "tail" contains n with 5 as a prime factor. Moving up within each "tail," the prime factors of each n tend to increase.

Examples

			For n=7, express 7 in all bases from 2 to 7, then add the numbers, counting those which are prime:
  base 2: 1 1 1 --> 1+1+1=3 prime
  base 3: 2 1   --> 2+1=3   prime
  base 4: 1 3   --> 1+3=4   nonprime
  base 5: 1 2   --> 1+2=3   prime
  base 6: 1 1   --> 1+1=2   prime
  base 7: 1     --> 1=1     nonprime
The sum of the digits of the base-b expansion of 7 in 4 different bases b (2, 3, 5, and 6) from base 2 to 7 is prime, so a(7)=4.
		

Crossrefs

Programs

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
    

A387305 Least k such that the Hamming weight (A000120) of n*k is prime.

Original entry on oeis.org

3, 3, 1, 3, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 19, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 1, 3, 19, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 1, 9, 3, 1, 1, 1, 1, 7, 1, 5, 3, 1, 1, 3, 3, 1, 19, 1, 1, 67, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 5, 1, 5, 3, 1, 1, 1, 1, 5, 1, 5, 3
Offset: 1

Views

Author

Pablo Cadena-Urzúa, Aug 25 2025

Keywords

Comments

a(n) is always odd.

Examples

			a(1) = 3 because A000120(1) = 1 (not prime), A000120(2) = 1, and A000120(3) = 2 (prime).
a(11) = 1 because A000120(11) = 3 (prime).
a(15) = 19 since 15*19 = 285 and A000120(285) = 5 (prime); for 1 <= k < 19 the value A000120(15*k) is not prime.
		

Crossrefs

Programs

  • Mathematica
    A387305[n_] := Module[{k = -1}, While[!PrimeQ[DigitSum[(k += 2)*n, 2]]]; k];
    Array[A387305, 100] (* Paolo Xausa, Sep 02 2025 *)
  • PARI
    a(n) = {my(k=1); while(!isprime(hammingweight(n*k)), k++); k};
    vector(100, n, a(n))  \\ first 100 terms
    
  • Python
    import sympy as sp
    def a(n, kmax=10**6):
        for k in range(1, kmax + 1):
            if sp.isprime((n*k).bit_count()):
                return k
        return None
    def A(N):
        return [a(n) for n in range(1, N + 1)]

Formula

a(n) = min{k >= 1 : A000120(n*k) is prime}.
a(n) = 1 if A000120(n) is prime (see A052294).
For all m >= 0, a(2^m) = 3.

A301797 a(n) = (4^prime(n) - 1)/3.

Original entry on oeis.org

5, 21, 341, 5461, 1398101, 22369621, 5726623061, 91625968981, 23456248059221, 96076792050570581, 1537228672809129301, 6296488643826193618261, 1611901092819505566274901, 25790417485112089060398421, 6602346876188694799461995861, 27043212804868893898596335048021
Offset: 1

Views

Author

André Dalwigk, Mar 26 2018

Keywords

Comments

Also, numbers with a prime number of bits 1 (cf. A001348), interleaved with bits 0. Or: odd numbers with alternating binary digits and a prime Hamming weight A000120, cf. A052294. - M. F. Hasler, Oct 16 2018

Examples

			For n = 1, the first prime number is 2, so a(1) = (4^2-1)/3 = (16-1)/3 = 15/3 = 5;
for n = 2, prime(2) = 3, so a(2) = (4^3-1)/3 = (64-1)/3 = 63/3 = 21;
for n = 5, prime(5) = 11, so a(5) = (4^(11)-1)/3 = (4194304-1)/3 = 4194303/3 = 1398101.
		

Crossrefs

Subsequence of A006995 and of A002450, which is a subsequence of A000975.
Also the intersection of A002450 and A052294.

Programs

  • Java
    public static int a(int n){ int p = 1; while(n > 0){ p++; if(!new String(new char[p]).matches("(..+?)\\1+|.?")){ n--; } } return ((int) Math.pow(4, p)-1)/3; }
    
  • Magma
    [(4^NthPrime(n) - 1)/3: n in [1..20]]; // Vincenzo Librandi, Oct 17 2018
  • Mathematica
    a[n_]:=(4^Prime[n] - 1)/3; Array[a, 50] (* Stefano Spezia, Oct 16 2018 *)
  • PARI
    a(n) = (4^prime(n) - 1)/3; \\ Michel Marcus, Mar 27 2018
    

Formula

a(n) = A002450(A000040(n)). - Michel Marcus, Mar 27 2018
Previous Showing 11-20 of 20 results.