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 31-40 of 40 results.

A374178 a(n) is the least prime p such that p and the next prime > p have exactly n common 1's in their binary expansion.

Original entry on oeis.org

2, 5, 19, 29, 181, 359, 379, 983, 3821, 3581, 8179, 16111, 81901, 98297, 131059, 131063, 524269, 917471, 3145679, 4128763, 16744423, 16776187, 58720223, 117440381, 266330047, 468713467, 536870879, 1073741309, 2147483629, 4294967231, 8589410287, 33285865469
Offset: 1

Views

Author

Hugo Pfoertner, Jul 08 2024

Keywords

Comments

1

Examples

			  a(n): 2       5         19           29              181
   np   3       7         23           31              191
      [1 0]  [1 0 1]  [1 0 0 1 1]  [1 1 1 0 1]  [1 0 1 1 0 1 0 1]
      [1 1]  [1 1 1]  [1 0 1 1 1]  [1 1 1 1 1]  [1 0 1 1 1 1 1 1]
       ^      ^   ^    ^     ^ ^    ^ ^ ^   ^    ^   ^ ^   ^   ^
  n:   1        2          3            4               5
		

Crossrefs

Programs

  • Python
    from sympy import nextprime
    def A374178(n):
        p = 2
        while (q:=nextprime(p)):
            if (p&q).bit_count() == n:
                return p
            p = q # Chai Wah Wu, Jul 08 2024

A381405 a(0) = 0; for n > 0, a(n) is the smallest unused number such that a(n) AND a(n-1) = 0, where AND is the binary AND operation, while the binary weight of a(n) does not equal that of a(n-1).

Original entry on oeis.org

0, 1, 6, 8, 3, 4, 9, 2, 5, 16, 7, 24, 32, 10, 21, 34, 13, 18, 37, 64, 11, 20, 35, 12, 19, 36, 25, 66, 28, 33, 14, 17, 38, 65, 22, 40, 23, 72, 39, 80, 15, 48, 67, 60, 128, 26, 68, 27, 96, 29, 98, 129, 30, 97, 130, 41, 86, 136, 49, 78, 144, 42, 85, 138, 53, 74, 132, 43, 84, 139, 52, 75, 148, 99, 140, 51, 76, 147, 44, 83, 160, 31, 192, 45, 82, 141, 50, 77, 146, 101
Offset: 0

Views

Author

Scott R. Shannon, Feb 22 2025

Keywords

Comments

In the first 100000 terms the fixed points are 0, 1, 28, 76, 543, 1580, although more likely exist.

Examples

			a(3) = 8 = 1000_2 as 8 is unused and a(2) = 6 = 110_2, and 1000_2 AND 110_2 = 0 while the binary weights of 8 and 6 are 1 and 2 respectively.
		

Crossrefs

A381406 a(0) = 0; for n > 0, a(n) is the smallest unused number such that a(n) OR a(n-1) = 2^k - 1, where OR is the binary OR operation and k>=1, while the binary weight of a(n) does not equal that of a(n-1).

Original entry on oeis.org

0, 1, 3, 2, 5, 7, 4, 11, 6, 13, 10, 15, 8, 23, 9, 14, 17, 30, 19, 12, 27, 20, 31, 16, 47, 18, 29, 22, 43, 21, 46, 25, 39, 24, 55, 26, 45, 50, 61, 34, 63, 28, 51, 44, 59, 36, 91, 37, 58, 69, 62, 33, 94, 35, 60, 67, 124, 71, 56, 79, 48, 95, 32, 127, 38, 57, 70, 121, 54, 41, 86, 107, 52, 75, 117, 42, 53, 74, 119, 40, 87, 104, 151, 105, 118, 73, 126, 49, 78, 115
Offset: 0

Views

Author

Scott R. Shannon, Feb 22 2025

Keywords

Comments

The fixed points begin 0, 1, 10, 315, 413, 415, 1551, 1559, 1797; there are likely infinitely more.

Examples

			a(4) = 5 = 101_2 as 5 is unused and a(3) = 2 = 10_2, and 101_2 OR 10_2 = 111_2 = 2^3 - 1, while the binary weights of 5 and 2 are 2 and 1 respectively.
		

Crossrefs

A145576 a(n) is the smallest prime with both exactly an n number of 0's and exactly an n number of 1's in its binary representation. a(n) = 0 if no such prime exists.

Original entry on oeis.org

2, 0, 37, 139, 541, 2141, 8287, 33119, 131519, 525247, 2098687, 8391679, 33561599, 134242271, 536895487, 2147548159, 8590061567, 34360196863, 137439412223, 549756861439, 2199026663423, 8796097216447, 35184380411903
Offset: 1

Views

Author

Leroy Quet, Oct 13 2008

Keywords

Examples

			a(3) = 37 = 100101 (base 2) is the smallest prime with three 0's and three 1's in its binary representation. - _R. J. Mathar_, Oct 14 2008
		

Crossrefs

Programs

  • Maple
    A000120 := proc(n) local d; add(d,d=convert(n,base,2)) ; end: A080791 := proc(n) local d,dgs; dgs := convert(n,base,2) ; nops(dgs)-add(d,d=dgs) ; end: A070939 := proc(n) max(1,ilog2(n)+1) ; end: A145576 := proc(n) local p,pbin; p := nextprime(2^(2*n-1)-1); while true do pbin := A070939(p) ; if pbin > 2*n then RETURN(0) ; elif pbin = 2*n then if A000120(p) = n and A080791(p) = n then RETURN(p) ; fi; fi; p := nextprime(p) ; od: end: seq(A145576(n),n=1..30) ; # R. J. Mathar, Oct 14 2008
    # Alternative:
    F:= proc(n) local c,x;
          c:= [$n+1..2*n-2];
          do
            x:= 2^(2*n-1)+1+add(2^(2*n-1-c[i]),i=1..n-2);
            if isprime(x) then return x fi;
            c:= combinat:-prevcomb(c, 2*n-2)
          od
    end proc:
    2, 0, seq(F(n),n=3..30); # Robert Israel, Sep 24 2017
  • Mathematica
    Table[SelectFirst[Prime@ Apply[Range, PrimePi@{2^(2 (n - 1)) + 1, 2^(2 n) - 1}], Union@ DigitCount[#, 2] == {n} &] /. k_ /; MissingQ@ k -> 0, {n, 12}] (* Michael De Vlieger, Sep 24 2017 *)

Extensions

Extended by R. J. Mathar and Ray Chandler, Oct 14 2008

A177858 Triangle in which row n gives the number of primes <= 2^n having k 1's in their binary representation, k=1..n.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 1, 2, 3, 0, 1, 3, 4, 2, 1, 1, 3, 6, 4, 4, 0, 1, 3, 9, 9, 8, 0, 1, 1, 3, 12, 13, 20, 0, 5, 0, 1, 4, 12, 23, 31, 8, 14, 4, 0, 1, 4, 16, 29, 48, 24, 38, 9, 3, 0, 1, 4, 18, 42, 73, 52, 72, 29, 17, 1, 0, 1, 4, 21, 53, 111, 80, 151, 81, 52, 5, 5, 0, 1, 4, 23, 62, 152, 158, 256, 186
Offset: 1

Views

Author

T. D. Noe, May 14 2010

Keywords

Comments

Every row begins with 1 because 2 is the only prime having one 1 in its binary representation. A row ends in 1 or 0, depending on whether 2^n-1 is prime or composite. The sum of terms in row n is A007053(n).

Crossrefs

Cf. A061712 (least prime having n 1's)

Programs

  • Mathematica
    nn=20; cnt=Table[0,{nn}]; Flatten[Table[Do[p=Prime[i]; c=Total[IntegerDigits[p,2]]; cnt[[c]]++, {i, 1+PrimePi[2^(n-1)], PrimePi[2^n]}]; Take[cnt,n], {n,nn}]]

A278477 Primes that set a new record for the Hamming weight.

Original entry on oeis.org

2, 3, 7, 23, 31, 127, 383, 991, 2039, 3583, 6143, 8191, 63487, 129023, 131071, 522239, 524287, 1966079, 4128767, 14680063, 33546239, 67108351, 201064447, 260046847, 536739839, 1073479679, 2147483647, 8581545983, 16911433727
Offset: 1

Views

Author

Joerg Arndt, Nov 23 2016

Keywords

Comments

The Mersenne primes (A000668) are a subsequence.

Crossrefs

Programs

  • Maple
    M:= 40: # to use A061712(1..M)
    A061712:= proc(n) local d,c,cands;
      for d from 0 do
        cands:= map(t -> 2^(n+d)-1 - add(2^(n-1+d-j), j=t),
            combinat:-choose([$1..n-2+d], d));
        for c in cands do if  isprime(c) then return c fi od
      od
    end proc:
    A061712(1):= 2:
    R:= map(A061712, [$1..M]):
    R[select(t -> R[t] < `if`(isprime(2^(M+1)-1), 2^(M+1)-1, 2^(M+2)+2^M-1) and R[t] = min(R[t..-1]), [$1..nops(R)])]; # Robert Israel, Nov 23 2016
  • PARI
    {my(h=0);forprime(p=2,10^11,my(t=hammingweight(p));if(t>h,print1(p,", ");h=t));}

A374179 a(n) is the least prime p such that the binary expansions of p and of the next prime q > p differ at exactly n positions, and p and q have the same binary length.

Original entry on oeis.org

2, 11, 47, 139, 157, 191, 1151, 1531, 3067, 7159, 20479, 36857, 49139, 98299, 360439, 917503, 1310719, 786431, 6291449, 5242877, 20971507, 58720253, 83886053, 201326557, 335544301, 402653171, 3489660919, 1879048183, 5368709117, 25769803751, 21474836479, 77309411323
Offset: 1

Views

Author

Hugo Pfoertner, Jul 09 2024

Keywords

Examples

			  a(n): 2       11           47               139                157
   np   3       13           53               149                163
      [1 0]  [1 0 1 1]  [1 0 1 1 1 1]  [1 0 0 0 1 0 1 1]  [1 0 0 1 1 1 0 1]
      [1 1]  [1 1 0 1]  [1 1 0 1 0 1]  [1 0 0 1 0 1 0 1]  [1 0 1 0 0 0 1 1]
         ^      ^ ^        ^ ^   ^            ^ ^ ^ ^          ^ ^ ^ ^ ^
  n:     1       2            3                  4                 5
		

Crossrefs

Programs

  • Python
    from sympy import nextprime
    def A374179(n):
        p, pb = 2, 2
        while (q:=nextprime(p)):
            if pb==(qb:=q.bit_length()) and (p^q).bit_count() == n:
                return p
            p, pb = q, qb  # Chai Wah Wu, Jul 10 2024

A140330 Smallest nonprime with Hamming weight n (i.e., with exactly n 1's when written in binary).

Original entry on oeis.org

1, 6, 14, 15, 55, 63, 247, 255, 511, 1023, 2047, 4095, 12287, 16383, 32767, 65535, 196607, 262143, 983039, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 3221225471
Offset: 1

Views

Author

Jonathan Vos Post, May 26 2008

Keywords

Comments

Apart from the first term, identical to A089226. - R. J. Mathar, May 31 2008

Examples

			a(10) = 1023 because 1023 base 2 = 1111111111 which has 10 1's and 1023 = 3 * 11 * 31 is nonprime.
		

Crossrefs

Cf. A061712.

Formula

a(n) = MIN{k such that k is in A018252 and A000120(k) = n}.

Extensions

More terms from R. J. Mathar, May 31 2008

A354480 a(n) is the smallest decimal palindrome with Hamming weight n (i.e., with exactly n 1's when written in binary).

Original entry on oeis.org

0, 1, 3, 7, 77, 55, 111, 191, 383, 767, 5115, 11711, 15351, 30703, 81918, 97279, 744447, 978879, 1570751, 3665663, 8387838, 66911966, 66322366, 132111231, 199212991, 389545983, 939474939, 3204444023, 3220660223, 11542724511, 34258485243, 33788788733, 34292629243
Offset: 0

Views

Author

Ilya Gutkovskiy, Jun 02 2022

Keywords

Crossrefs

Programs

  • Python
    from itertools import count, islice, product
    def pals(startd=1): # generator for base-10 palindromes
        for d in count(startd):
            for p in product("0123456789", repeat=d//2):
                if d//2 > 0 and p[0] == "0": continue
                left = "".join(p); right = left[::-1]
                for mid in [[""], "0123456789"][d%2]:
                    yield int(left + mid + right)
    def a(n):
        for p in pals(startd=len(str(2**n-1))):
            if bin(p).count("1") == n:
                return p
    print([a(n) for n in range(33)]) # Michael S. Branicky, Jun 02 2022

Extensions

a(21)-a(32) from Michael S. Branicky, Jun 02 2022

A362979 Square array, read by descending antidiagonals: row n lists the primes whose base-2 representation has exactly n ones, starting from n=3.

Original entry on oeis.org

7, 11, 23, 13, 29, 31, 19, 43, 47, 311
Offset: 3

Views

Author

Clark Kimberling, May 11 2023

Keywords

Examples

			Corner:
  n=3:    7    11    13    19    37   41     67    73    97
  n=4:   23    29    43    53    71   83     89   101   113
  n=5:   31    47    59    61    79   103   107   109   151
  n=6:  311   317   347   349   359   373   461   467   571
The first four primes in row n=3 have these base-2 representations, respectively: 111, 1011, 1101, 10011.
		

Crossrefs

Cf. A019434 (row 2), A061712 (column 1), A081091 (row 3), A095077 (row 4).

Programs

  • Mathematica
    t[n_] := Count[IntegerDigits[Prime[n], 2], 1]  (* A014499 *)
    u = Table[t[n], {n, 1, 200}];
    p[n_] := Flatten[Position[u, n]]
    w = TableForm[Table[Prime[p[n]], {n, 3, 16}]]

Extensions

New offset and edited by Michel Marcus, Jan 19 2024
Previous Showing 31-40 of 40 results.