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.

User: Mareike Fischer

Mareike Fischer's wiki page.

Mareike Fischer has authored 7 sequences.

A386912 The base-2 logarithm of this sequence equals the Q statistic value of the greedy-from-the-bottom tree with n leaves, which is the minimal Q statistic value for n.

Original entry on oeis.org

1, 2, 6, 16, 60, 192, 672, 2048, 8640, 30720, 118272, 393216, 1597440, 5505024, 20643840, 67108864, 300810240, 1132462080, 4602200064, 16106127360, 68702699520, 248034361344, 972407439360, 3298534883328, 14495514624000, 53601191854080
Offset: 1

Author

Mareike Fischer, Aug 07 2025

Keywords

Examples

			a(1)=1, because a(1)=Product(i=2..1)=1 (empty product).
a(2)=2, because q(2,2)=1, so a(2)=2^q(2,2)=2^1=2.
a(3)=6, because q(3,2)=1 and q(3,3)=1, so a(3)=2^q(3,2)*3^q(3,3)=2^1*3^1=6.
		

Crossrefs

Cf. A132862.

Programs

  • Maple
    a:= proc(n) option remember; `if`(n<2, 1, (b-> (f->
          a(f)*n*a(n-f))(min(b, n-b/2)))(2^ilog2(n-1)))
        end:
    seq(a(n), n=1..26);  # Alois P. Heinz, Aug 18 2025
  • Mathematica
    q[n_, i_] := Module[{factor, ki}, factor = FactorInteger[i];
      ki = Ceiling[Log2[i]];
      If[(i == 1 || i == n), Return[n/i],
       If[(Length[factor] == 1 && factor[[1]][[1]] == 2),
         If[(Mod[n, i] == 0 || Mod[n, i] >= 2^(ki - 1)),
          Return[Floor[n/i]], Return[Floor[n/i] - 1]],
         If[Mod[n - i, 2^(ki - 1)] == 0, Return[1], Return[0]]];
       ]];
    a[n_] := Product[i^q[n, i], {i, 2, n}]; alist = {};
    For[n = 1, n <= 300, n++, AppendTo[alist, a[n]]]; Print[alist]
    (* Alternative, after Alois P. Heinz: *)
    A386912[n_] := A386912[n] = If[n == 1, 1, n*A386912[#]*A386912[n - #]] & [Min[#, n - #/2] & [2^(BitLength[n - 1] - 1)]]; Array[A386912, 30] (* Paolo Xausa, Aug 19 2025 *)
  • Python
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def a(n: int) -> int:
        if n < 2: return 1
        b = 1 << ((n - 1).bit_length() - 1)
        f = min(b, n - b // 2)
        return a(f) * n * a(n - f)
    print([a(n) for n in range(1, 27)])  # after Alois P. Heinz, Peter Luschny, Aug 19 2025

Formula

a(n) = Product_{i=2..n} i^q(n,i), with k(i)=ceiling(log_2(i)) and q(n,i)=floor(n/i) if (i=2^(k(i)) and ((n mod i)=0 or (n mod i)>=2^(k(i)-1))), and q(n,i)=floor(n/i)-1 if (i=2^(k(i)) and (0 < (n mod i)< 2^(k(i)-1))) and q(n,i)=1 if (i!=2^(k(i)) and ( (n-i) mod 2^(k(i)-1)) =0 ) and q(n,i)=0 if (i!=2^(k(i)) and ( (n-i) mod 2^(k(i)-1)) >0 ).
a(n) = Product_{i=0..k(n)-1} (2^(k(n)-i))^(2^i) if d(n)=2^(k(n)-1). Else, a(n) = Product_{i=0..k(n)-2} (2^(k(n)-i-1))^(2^i) * 2^d(n) * Product_{i=1..k(n)-1} ( 2^floor(d(n)/(2^i)) * ((2^i + (d(n)-2^i*(floor(d(n)/(2^i))))) / (2^i) )^(ceiling(d(n)/2^i)-floor(d(n)/(2^i))) if d(n) < 2^(k(n)-1), with k(n)=ceiling(log_2(n)) and d(n)=n-2^(k(n)-1).
a(n) = n*a(f)*a(n-f) with f = min(b,n-b/2) and b = 2^floor(log_2(n-1)) for n>1, a(1) = 1. - Alois P. Heinz, Aug 18 2025

A344852 Number of rooted binary trees with n leaves with minimal Symmetry Nodes Index (SNI) or, equivalently, with the maximal number of symmetry nodes.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 1, 3, 3, 15, 1, 1, 1, 3, 1, 3, 3, 15, 1, 3, 3, 15, 3, 15, 15, 105, 1, 1, 1, 3, 1, 3, 3, 15, 1, 3, 3, 15, 3, 15, 15, 105, 1, 3, 3, 15, 3, 15, 15, 105, 3, 15, 15, 105, 15, 105, 105, 945, 1, 1, 1, 3, 1, 3, 3, 15, 1, 3, 3, 15, 3, 15, 15, 105, 1, 3, 3, 15, 3, 15, 15, 105, 3, 15, 15, 105, 15, 105, 105, 945, 1
Offset: 1

Author

Mareike Fischer, Jun 15 2021

Keywords

Comments

In a rooted binary tree, each internal node has precisely two children. An internal node is called a symmetry node if the subtrees of its two children are isomorphic. The Symmetry Nodes Index SNI, however, counts the internal nodes which are not symmetry nodes. The minimal SNI of a rooted binary tree with n leaves is wt(n)-1, where wt(n) = A000120(n) denotes the binary weight of n, i.e., it refers to the number of 1's in the binary expansion of n.
a(n) is also the number of trees with n leaves and minimal Rogers's J tree balance index, which is the number of internal nodes which are not balanced, i.e., the number of nodes whose left and right subtrees do not have the same number of leaves.

Examples

			a(7)=2, because both trees (((x,x),(x,x)),((x,x),x)) and (((x,x),(x,x),x),(x,x)) have four inner nodes which are symmetry nodes and only two inner nodes which are non-symmetry nodes. So the SNI of both trees equals 2, which is minimal for n=7.
a(8)=1, because only the tree (((x,x),(x,x)),((x,x),(x,x))) is minimal: its SNI equals 0.
		

Crossrefs

Programs

  • Maple
    a:= n-> doublefactorial(2*add(i, i=convert(n, base, 2))-3):
    seq(a(n), n=1..100); # Georg Fischer, Jun 15 2021
  • Mathematica
    a[n_] := (2*DigitCount[n, 2, 1] - 3)!!; Table[a[n], {n, 1, 100}]
  • PARI
    a(n)={my(t=hammingweight(n)-1); (2*t)!/(2^t*t!)} \\ Andrew Howroyd, Jun 15 2021

Formula

a(n) = (2*wt(n) - 3)!! = A001147(2*A000120(n) - 3).

A345135 Number of ordered rooted binary trees with n leaves and with minimal Sackin tree balance index.

Original entry on oeis.org

1, 1, 1, 2, 1, 4, 6, 4, 1, 8, 28, 56, 70, 56, 28, 8, 1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1, 32, 496, 4960, 35960, 201376, 906192, 3365856, 10518300, 28048800, 64512240, 129024480, 225792840, 347373600, 471435600
Offset: 0

Author

Mareike Fischer, Jun 09 2021

Keywords

Comments

Ordered rooted binary trees are trees with two descendants per inner node where left and right are distinguished.
The Sackin tree balance index is also known as total external path length.
a(0) = 1 by convention.

Examples

			a(1) = a(2) = 1 because there are only the trees (o) and (o,o) which get counted. a(3) = 2 because the trees ((o,o),o) and (o,(o,o)) get counted. a(4) = 1 because only the tree ((o,o),(o,o)) is counted. Note that the other possible rooted binary ordered trees with four leaves, namely the different orderings of (((o,o),o),o), are not Sackin minimal. a(5) = 4 because the following trees get counted: (((o,o),o),(o,o)), ((o,(o,o)),(o,o)), ((o,o),((o,o),o)), ((o,o),(o,(o,o))).
		

Programs

  • Maple
    a:= n-> (b-> binomial(b, n-b))(2^ilog2(n)):
    seq(a(n), n=0..46);  # Alois P. Heinz, Jun 09 2021
  • Mathematica
    a[0] := 1; a[n_] := Module[{k = 2^(BitLength[n] - 1)}, Binomial[k, n - k]];
    Table[a[n], {n, 0, 46}]

Formula

a(n) = binomial(2^(ceiling(log_2(n))-1),n-2^(ceiling(log_2(n))-1)).
a(n) = binomial(A053644(n),n-A053644(n)).
a(2^n) = 1.
a(2^n-1) = A011782(n).
a(2^n+1) = A000079(n).
From Alois P. Heinz, Jun 09 2021: (Start)
max({ a(k) | k = 2^n..2^(n+1) }) = A037293(n).
Sum_{i=2^n..2^(n+1)-1} a(i) = 2^(2^n) - 1 = A051179(n). (End)
Conjecture: Sum_{n>=0} a(n)*x^n = 1 + x + Sum_{n>=0} x^(2^n) * ((1 + x)^(2^n) - 1). - Paul D. Hanna, Jul 18 2024

A344934 Number of rooted binary phylogenetic trees with n leaves and minimal Sackin tree balance index.

Original entry on oeis.org

1, 1, 3, 3, 30, 135, 315, 315, 11340, 198450, 2182950, 16372125, 85135050, 297972675, 638512875, 638512875, 86837751000, 5861548192500, 259861969867500, 8445514020693750, 212826953321482500, 4292010225316563750, 70511596558772118750, 951906553543423603125, 10576739483815817812500, 96248329302723942093750
Offset: 1

Author

Mareike Fischer, Jun 09 2021

Keywords

Comments

Rooted binary phylogenetic trees with n leaves are rooted trees for which each internal node has precisely two children and whose leaves are bijectively labeled by the set {1,...,n}.

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[{k = Ceiling[Log2[n]], int, na, nb, sum, i},
      If[n == 1, Return[1],
       int = IntegerPartitions[n, {2}];
       If[OddQ[n], sum = 0, sum = 1/2*Binomial[n, n/2]*((a[n/2])^2)];
       For[i = 1, i <= Length[int], i++,
        na = int[[i]][[1]]; nb = int[[i]][[2]];
        If[na > n/2 && na <= 2^(k - 1) && nb >= 2^(k - 2),
         sum = sum + Binomial[n, na]*a[na]*a[nb];
         ];
        ];
       Return[sum];
       ]]
  • PARI
    seq(n)={my(a=vector(n)); a[1]=1; for(n=2, #a, my(k=1+logint(n-1,2)); a[n]=if(n%2==0, a[n/2]*binomial(n,n/2)/2) + sum(i=n\2+1, min(2^(k-1), n-2^(k-2)), binomial(n,i)*a[i]*a[n-i])); a} \\ Andrew Howroyd, Jun 09 2021

Formula

With k:=log_2(n) and g(n):=0 if n is odd and g(n) := (1/2)*binomial(n,n/2)*a(n/2) if n is even and pairs := set of all pairs (na,nb) such that na+nb=n and na >= nb and na > n/2 and na <= 2^(k-1) and nb >= 2^(k-2), we get:
a(n) = g(n) + sum over all described pairs (na,nb): binomial(n,na)*a(na)*a(nb).
a(n) = g(n) + Sum_{i=floor(n/2)+1..2^(k-1), i <= 2^(k-2)} binomial(n,i)*a(i)*a(n-i), where k = ceiling(log_2(n)) and g(n)=0 for odd n, g(n) = binomial(n,n/2)*a(n/2)/2 for even n.

A344613 Number of rooted binary trees (in which all inner nodes have precisely two children) with n leaves and with maximal number of cherries (i.e., maximal number of pendant subtrees with two leaves).

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 4, 2, 9, 3, 20, 6, 46, 11, 106, 23, 248, 46, 582, 98, 1376, 207, 3264, 451, 7777, 983, 18581, 2179, 44526, 4850, 106936, 10905, 257379, 24631, 620577, 56011, 1498788, 127912, 3625026, 293547, 8779271, 676157, 21287278, 1563372, 51671864, 3626149, 125550018
Offset: 1

Author

Mareike Fischer, Jun 09 2021

Keywords

Comments

This sequence describes the number of rooted binary trees with n leaves with maximal cherry tree balance index or, equivalently, with minimal modified cherry tree balance index.

Crossrefs

Programs

  • Maple
    b:= proc(n) option remember; `if`(n<2, n, `if`(n::odd, 0,
          (t-> t*(1-t)/2)(b(n/2)))+add(b(i)*b(n-i), i=1..n/2))
        end:
    g:= proc(n) option remember; `if`(n<1, 1,
          add(g(n-i)*b(i), i=1..n))
        end:
    a:= n-> `if`(n::even, b(n/2), g((n-1)/2)):
    seq(a(n), n=1..52);  # Alois P. Heinz, Jun 09 2021
  • Mathematica
    (* WE generates the Wedderburn Etherington Numbers, OEIS sequence A001190 *)
    WE[n_] := Module[{i},
       If[n == 1, Return[1],
        If[Mod[n, 2] == 0,
         Return[
          WE[n/2]*(WE[n/2] + 1)/2 + Sum[WE[i]*WE[n - i], {i, 1, n/2 - 1}]],
         Return[Sum[WE[i]*WE[n - i], {i, 1, Floor[n/2]}]]
         ]
        ]
       ];
    (* b is just a support function *)
    b[n_] := b[n] =
       If[n < 2, n,
        If[OddQ[n], 0, Function[t, t*(1 - t)/2][b[n/2]]] +
         Sum[b[i]*b[n - i], {i, 1, n/2}]];
    (* c generates the elements of OEIS sequence A085748 *)
    c[n_] := c[n] = If[n < 1, 1, Sum[c[n - i]*b[i], {i, 1, n}]];
    (* a generates the number of rooted binary trees with maximal number of cherries *)
    a[n_] := Module[{},
      If[EvenQ[n], Return[WE[n/2]], Return[c[(n - 1)/2]]]]

Formula

a(n) = A001190(n/2) if n even, otherwise a(n) = A085748((n-1)/2).

A307689 The number of rooted binary trees on n leaves with minimal Colless index.

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 3, 4, 3, 3, 1, 1, 1, 4, 6, 10, 16, 21, 13, 11, 13, 21, 16, 10, 6, 4, 1, 1, 1, 5, 10, 20, 50, 82, 73, 66, 184, 411, 548, 351, 455, 326, 144, 67, 144, 326, 455, 351, 548, 411, 184, 66, 73, 82, 50, 20, 10, 5, 1, 1
Offset: 1

Author

Mareike Fischer, Apr 22 2019

Keywords

Comments

a(n) is the number of maximally balanced binary rooted trees with n leaves according to the Colless imbalance index. It is bounded above by sequence A299037.

Examples

			There are 13 trees with minimal Colless index and 23 leaves, i.e. a(23)=13.
		

Crossrefs

The sequence is bounded above by A299037.
The sequence of the number of trees with minimal Colless index is also linked to the values of the minimal Colless index as given by A296062.

Programs

  • Mathematica
    (*QB[n] is just a support function -- the function that actually generates the sequence of the numbers of trees with minimal Colless index and n leaves is given by minCbasedonQB; see below*)
    QB[n_] := Module[{k, n0, bin, l, m = {}, i, length, qb = {}, j},
      If[OddQ[n], k = 0,
       k = FactorInteger[n][[1]][[2]];
       ];
      n0 = n/(2^k);
      bin = IntegerDigits[n0, 2];
      length = Length[bin];
      For[i = Length[bin], i >= 1, i--,
       If[bin[[i]] != 0, PrependTo[m, length - i]];
       ];
      l = Length[m];
      If[l == 1, Return[{{n/2, n/2}}],
       AppendTo[
        qb, {2^k*(Sum[2^(m[[i]] - 1), {i, 1, l - 1}] + 1),
         2^k*(Sum[2^(m[[i]] - 1), {i, 1, l - 1}])}];
       For[j = 2, j <= l - 1, j++,
        If[m[[j]] > m[[j + 1]] + 1,
         AppendTo[
          qb, {2^k*(Sum[2^(m[[i]] - 1), {i, 1, j - 1}] + 2^m[[j]]),
           n - 2^k*(Sum[2^(m[[i]] - 1), {i, 1, j - 1}] + 2^m[[j]])}]];
        If[m[[j]] < m[[j - 1]] - 1,
         AppendTo[
          qb, {n - 2^k*Sum[2^(m[[i]] - 1), {i, 1, j - 1}],
           2^k*Sum[2^(m[[i]] - 1), {i, 1, j - 1}]}]];
        ];
       If[k >= 1, AppendTo[qb, {n/2, n/2}]];
       Return[qb];
       ];
      ]
    minCbasedonQB[n_] := Module[{qb = QB[n], min = 0, i, na, nb},
      If[n == 1, Return[1],
       For[i = 1, i <= Length[qb], i++,
        na = qb[[i]][[1]]; nb = qb[[i]][[2]];
        If[na != nb, min = min + minCbasedonQB[na]*minCbasedonQB[nb],
         min = min + Binomial[minCbasedonQB[n/2] + 1, 2]];
        ];
       Return[min];
       ]
      ]

Formula

a(1)=1; a(n) = Sum_{(n_a,n_b): n_a+n_b=n, n_a > n_b, (n_a,n_b) in QB(n)}} ( a(n_a)* a(n_b)) +f(n), where f(n)=0 if n is odd} and f(n)= binomial(a(n/2)+1,2) if n is even; and where QB(n)={(n_a,n_b): n_a+n_b=n and such that there exists a tree T on n leaves with minimal Colless index and with leaf partitioning (n_a,n_b)} }.

A299037 a(n) is the number of rooted binary trees with minimal Sackin index and n leaves.

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 3, 5, 3, 3, 1, 1, 1, 4, 6, 14, 17, 27, 28, 35, 28, 27, 17, 14, 6, 4, 1, 1, 1, 5, 10, 30, 55, 121, 207, 378, 575, 894, 1217, 1651, 1993, 2373, 2546, 2682, 2546, 2373, 1993, 1651, 1217, 894, 575, 378, 207, 121, 55, 30, 10, 5, 1, 1, 1, 6, 15, 55, 135, 381, 903, 2205, 4848, 10599, 21631
Offset: 1

Author

Mareike Fischer, Feb 01 2018

Keywords

Comments

a(n) is also the number of maximally balanced trees with n leaves according to the Sackin index.
From Omar E. Pol, Feb 02 2018: (Start)
Also the sequence can be written as an irregular triangle read by rows in which the row lengths are the terms of A011782 (see example section).
Column 1 gives A000012. Column 2 gives A000027.
Conjecture 1: column 3 gives the nonzero terms of A000217.
Conjecture 2: column 4 gives the nonzero terms of A000330. (End)
Comment from the author, Feb 02 2018: Denote the (i,j)-th entry of the irregular triangle described above (row i, column j) with T(i,j), i >= 1 and 1 <= j <= A011782(i-1). Then, rows 1 and 2 contain a 1 each (and they denote the number of trees minimizing the Sackin index with 1 and two leaves, respectively) and row i ranges from 2^(i-2) + 1 to 2^(i-1) leaves and for each of these numbers gives the number of trees with minimum Sackin index. E.g., row 4 gives the number of such trees for 2^(4-2) + 1 = 5 leaves up to 2^(4-1) = 8 leaves.
From Omar E. Pol, Mar 01 2018: (Start)
Conjecture 3: column 5 gives the nonzero terms of A212415.
Conjecture 4: row sums give 1 together with A006893.
Conjecture 5: T(i,j) has i >= 0 where "i" is the height of the rooted trees.
Conjecture 6: For i >= 1, j is the number of leaves minus 2^(i-1). (End)

Examples

			Whenever n = 2^k, i.e., n is a power of 2, then the tree minimizing the Sackin index is unique, namely the so-called fully balanced tree of height k.
From _Omar E. Pol_, Feb 01 2018: (Start)
Written as an irregular triangle the sequence begins:
  1;
  1;
  1, 1;
  1, 2, 1,  1;
  1, 3, 3,  5,  3,  3,  1,  1;
  1, 4, 6, 14, 17, 27, 28, 35, 28, 27, 17, 14, 6, 4, 1, 1;
  ... (End)
		

Crossrefs

Cf. A001190 (number of rooted binary trees with n leaves), A011782.

Programs

  • Mathematica
    maxnumber = 1024;
    minlist = {1}; For[n = 2, n <= maxnumber, n++,
    parts = IntegerPartitions[n, {2}];
    total = 0;
    For[s = 1, s <= Length[parts], s++,
      na = parts[[s]][[1]]; nb = parts[[s]][[2]]; k = Ceiling[Log2[n]];
      ka = Ceiling[Log2[na]]; kb = Ceiling[Log2[nb]];
      If[na >= n/2 && ka == k - 1 && kb == k - 1 && na != nb,
       total = total + minlist[[na]]*minlist[[nb]],
       If[na >= n/2 && ka == k - 1 && kb == k - 1 && na == nb,
        total = total + Binomial[minlist[[na]] - 1 + 2, 2],
        If[na >= n/2 && nb == 2^(k - 2) && ka == k - 1,
         total = total + minlist[[na]]]]];
      ]; AppendTo[minlist, total];
    ]

Formula

a(1) = 1.
a(n) = Sum_{(n_a,n_b): n_a+n_b=n, n_a>=n/2, ceiling(log_2(n_a)) = ceiling(log_2(n))-1, ceiling(log_2(n_b)) = ceiling(log_2(n))-1,n_a!=n_b} a(n_a)*a(n_b) + Sum_{(n_a,n_b): n_a+n_b=n, ceiling(log_2(n_a)) = ceiling(log_2(n)) - 1, ceiling(log_2(n_b)) = ceiling(log_2(n)) - 1, n_a = n_b} binomial(a(n_a)+1,2) + Sum_{(n_a,n_b): n_a+n_b=n, ceiling(log_2(n_a)) = ceiling(log_2(n)) - 1, n_b = 2^(ceiling(log_2(n))-2)} a(n_a).