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.

A331855 a(n) is the number of distinct values obtained by partitioning the binary representation of n into consecutive blocks, and then reversing those blocks.

Original entry on oeis.org

1, 1, 2, 1, 3, 3, 3, 1, 4, 6, 5, 4, 5, 4, 4, 1, 5, 10, 9, 9, 8, 8, 9, 5, 7, 9, 8, 5, 7, 5, 5, 1, 6, 15, 14, 16, 12, 16, 18, 12, 11, 16, 13, 12, 15, 13, 14, 6, 9, 16, 15, 13, 13, 12, 12, 6, 10, 12, 11, 6, 9, 6, 6, 1, 7, 21, 20, 25, 18, 27, 30, 22, 16, 27, 25
Offset: 0

Views

Author

Rémy Sigrist, Jan 29 2020

Keywords

Examples

			For n = 6:
- the binary representation of 6 is "110",
- we can split it in 4 ways:
      "110" -> "011" -> 3
      "1" and "10" -> "1" and "01" -> 5
      "11" and "0" -> "11" and "0" -> 6
      "1" and "1" and "0" -> "1" and "1" and "0" -> 6
- we have 3 distinct values,
- hence a(6) = 3.
		

Crossrefs

See A331851 for similar sequences.
See A331856 and A331857 for the least and greatest values, respectively.

Programs

  • PARI
    See Links section.

Formula

a(2^k-1) = 1 for any k >= 0.
a(2^k) = k+1 for any k >= 0.
a(2^k+1) = A000217(k) for any k > 0.
a(2^k+2) = A000096(k-1) for any k > 3.
a(2^k+3) = (k-1)^2 for any k > 1.

A331857 a(n) is the greatest value obtained by partitioning the binary representation of n into consecutive blocks, and then reversing those blocks.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 6, 7, 8, 12, 12, 14, 12, 14, 14, 15, 16, 24, 24, 28, 24, 26, 28, 30, 24, 28, 28, 30, 28, 30, 30, 31, 32, 48, 48, 56, 48, 52, 56, 60, 48, 52, 52, 58, 56, 58, 60, 62, 48, 56, 56, 60, 56, 58, 60, 62, 56, 60, 60, 62, 60, 62, 62, 63, 64, 96, 96
Offset: 0

Views

Author

Rémy Sigrist, Jan 29 2020

Keywords

Examples

			For n = 6:
- the binary representation of 6 is "110",
- we can split it in 4 ways:
      "110" -> "011" -> 3
      "1" and "10" -> "1" and "01" -> 5
      "11" and "0" -> "11" and "0" -> 6
      "1" and "1" and "0" -> "1" and "1" and "0" -> 6
- we have 3 distinct values, the greatest being 6,
- hence a(6) = 6.
		

Crossrefs

See A331855 for the number of distinct values, and A331856 for the least value.

Programs

  • PARI
    See Links section.

Formula

a(n)^A023416(n) = A073138(n) (where a^k denotes the k-th iterate of n).
a(n) >= n with equality iff n belongs to A023758.

A373886 a(n) is the least number whose binary expansion can be obtained by reversing one or more consecutive bits in the binary expansion of n.

Original entry on oeis.org

0, 1, 1, 3, 1, 3, 3, 7, 1, 3, 5, 7, 3, 7, 7, 15, 1, 3, 6, 7, 5, 11, 13, 15, 3, 7, 11, 15, 7, 15, 15, 31, 1, 3, 6, 7, 9, 13, 14, 15, 5, 11, 21, 23, 13, 27, 29, 31, 3, 7, 14, 15, 11, 23, 27, 31, 7, 15, 23, 31, 15, 31, 31, 63, 1, 3, 6, 7, 12, 13, 14, 15, 9, 19
Offset: 0

Views

Author

Rémy Sigrist, Aug 10 2024

Keywords

Comments

This sequence has similarities with A087734; here we reverse some consecutive bits, there we negate some consecutive bits.

Examples

			The first terms, alongside their binary expansion, are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     1      10          1
   3     3      11         11
   4     1     100          1
   5     3     101         11
   6     3     110         11
   7     7     111        111
   8     1    1000          1
   9     3    1001         11
  10     5    1010        101
  11     7    1011        111
  12     3    1100         11
  13     7    1101        111
  14     7    1110        111
  15    15    1111       1111
  16     1   10000          1
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local L,nL,i,j,k,r,x;
      L:= convert(n,base,2);
      nL:= nops(L);
      r:= n;
      for i from 1 to nL-1 do
        for j from i+1 to nL do
          r:= min(r, n + add((L[j-k]-L[i+k])*2^(i+k-1),k=0..j-i));
      od od;
      r
    end proc:
    map(f, [$0..100]); # Robert Israel, Aug 13 2024
  • PARI
    a(n, base = 2) = { my (d = if (n, digits(n, base), [0])); setbinop((i, j) -> fromdigits(concat([d[1..i-1], Vecrev(d[i..j]), d[j+1..#d]]), base), [1..#d])[1]; }
    
  • Python
    def a(n):
        b = bin(n)[2:]
        return min(int(b[:i]+b[i:j][::-1]+b[j:], 2) for i in range(len(b)) for j in range(i, len(b)+1))
    print([a(n) for n in range(74)]) # Michael S. Branicky, Aug 13 2024

Formula

a(n) <= n with equality iff n belongs to A000225.
a^k(n) = A038573(n) for k sufficiently large (where a^k denotes the k-th iterate of the sequence).
a(2^k) = 1 for any k >= 0.
A000120(a(n)) = A000120(n).
Showing 1-3 of 3 results.