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

A335039 Numbers whose binary representation encodes a (binary) max-heap on elements from the set {0,1} with root at the least significant bit.

Original entry on oeis.org

0, 1, 3, 5, 7, 11, 15, 19, 23, 27, 31, 37, 39, 47, 55, 63, 69, 71, 79, 87, 95, 101, 103, 111, 119, 127, 139, 143, 155, 159, 175, 191, 207, 223, 239, 255, 267, 271, 283, 287, 303, 319, 335, 351, 367, 383, 395, 399, 411, 415, 431, 447, 463, 479, 495, 511, 531
Offset: 1

Views

Author

Alois P. Heinz, May 20 2020

Keywords

Comments

All positive terms are odd.

Crossrefs

Cf. A000225 (subsequence), A335040, A335041, A335042.

Programs

  • Maple
    q:= proc(n) local i, l; l:= convert(n, base, 2);
          for i from 2 to nops(l) do
            if l[i]>l[iquo(i, 2)] then return false fi
          od; true
        end:
    a:= proc(n) option remember; local k: for k from 1+
          `if`(n=1, -1, a(n-1)) while not q(k) do od; k
        end:
    seq(a(n), n=1..59);

A335041 Numbers whose binary representation encodes a (binary) min-heap on elements from the set {0,1} with root at the least significant bit.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 7, 8, 10, 12, 14, 15, 16, 20, 24, 26, 28, 30, 31, 32, 36, 40, 44, 48, 52, 56, 58, 60, 62, 63, 64, 72, 80, 88, 90, 96, 100, 104, 108, 112, 116, 120, 122, 124, 126, 127, 128, 136, 144, 152, 154, 160, 168, 176, 184, 186, 192, 200, 208, 216, 218
Offset: 1

Views

Author

Alois P. Heinz, May 20 2020

Keywords

Comments

All odd terms are in A000225.

Crossrefs

Cf. A000225 (subsequence), A335039, A335040, A335042 (subsequence).

Programs

  • Maple
    q:= proc(n) local i, l; l:= convert(n, base, 2);
          for i from 2 to nops(l) do
            if l[i]
    				

A335042 Numbers whose binary representation encodes a (binary) max-heap on elements from the set {0,1} with root at the most significant bit and a min-heap with root at the least significant bit.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 7, 8, 10, 12, 14, 15, 16, 20, 24, 26, 28, 30, 31, 32, 40, 48, 52, 56, 58, 60, 62, 63, 64, 80, 96, 100, 104, 108, 112, 116, 120, 122, 124, 126, 127, 128, 160, 192, 200, 208, 216, 224, 228, 232, 236, 240, 244, 248, 250, 252, 254, 255, 256, 320
Offset: 1

Views

Author

Alois P. Heinz, May 20 2020

Keywords

Comments

All odd terms are in A000225.

Crossrefs

Cf. A000225 (subsequence), A335039, A335040, A335041.

Programs

  • Maple
    q:= proc(n) local i, l; l:= convert(n, base, 2);
          for i from 2 to nops(l) do if (h-> l[i]l[-h])(iquo(i, 2)) then return false fi
          od; true
        end:
    a:= proc(n) option remember; local k: for k from 1+
          `if`(n=1, -1, a(n-1)) while not q(k) do od; k
        end:
    seq(a(n), n=1..62);

Formula

{ A335040 } intersect { A335041 }.

A380856 In the binary expansion of n, arrange bits row-wise in a binary tree which is complete except for the last row and then read those bits in pre-order.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 11, 12, 14, 13, 15, 16, 18, 20, 22, 17, 19, 21, 23, 24, 26, 28, 30, 25, 27, 29, 31, 32, 33, 36, 37, 40, 41, 44, 45, 34, 35, 38, 39, 42, 43, 46, 47, 48, 49, 52, 53, 56, 57, 60, 61, 50, 51, 54, 55, 58, 59, 62, 63, 64, 65, 66, 67, 72
Offset: 0

Views

Author

DarĂ­o Clavijo, Feb 06 2025

Keywords

Comments

The formed tree is a max-heap when n is in A335040, also is strict if n is in A053738 and not strict if n is in A053754.
The re-ordering of the bits depends only on the bit length of n (cf. A379905), and the two most significant bits are always fixed.
If the remaining bits are all 0's or all 1's then re-ordering them is no change so that fixed points a(n) = n include n = 2^k or 2^k-1.

Examples

			For n = 65537, its binary expansion 10000000000000001 is arranged by rows in the following tree
            ______1______
           /             \
        __0__           __0__
       /     \         /     \
      0       0       0       0
     / \     / \     / \     / \
    0   0   0   0   0   0   0   0
   / \
  0   1
Reading this in pre-order is binary 10000100000000000 so that a(65537) = 67584.
		

Crossrefs

Cf. A378496 (inverse permutation).

Programs

  • Maple
    a:= proc(n) uses Bits; local b, l; b, l:= i->
          `if`(i>nops(l), [], [b(2*i+1)[], b(2*i)[], l[-i]]),
           Split(n); Join(b(1))
        end:
    seq(a(n), n=0..68);  # Alois P. Heinz, Feb 06 2025
  • Mathematica
    a[n_Integer] := Module[{res = {}, data, len},
      data = IntegerDigits[n, 2];
      len = Length[data];
      Which[
       MemberQ[{0, 1, 2}, n], n,
       True,
       DepthFirstScan[TreeGraph[Table[Floor[j/2] -> j, {j, 2, len}]],
        1, {"PrevisitVertex" -> (AppendTo[res, #] &)}];
       FromDigits[data[[res]], 2]]]; a /@ Range[0, 68]
     (* Shenghui Yang, Feb 14 2025 *)
  • Python
    from binarytree import Node, build
    a = lambda n: int("".join([node.value for node in build(bin(n)[2:]).preorder]),2)
    print([a(n) for n in range(1, 69)])
Showing 1-4 of 4 results.