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

A365968 Irregular triangle read by rows: T(n,k) (0 <= n, 0 <= k < 2^n). An infinite binary tree with root node 0 in row n = 0. Each node then has left child (2*j) - k - 1 and right child (2*j) - k + 1, where j and k are the values of the parent and grandparent nodes respectively.

Original entry on oeis.org

0, -1, 1, -3, -1, 1, 3, -6, -4, -2, 0, 0, 2, 4, 6, -10, -8, -6, -4, -4, -2, 0, 2, -2, 0, 2, 4, 4, 6, 8, 10, -15, -13, -11, -9, -9, -7, -5, -3, -7, -5, -3, -1, -1, 1, 3, 5, -5, -3, -1, 1, 1, 3, 5, 7, 3, 5, 7, 9, 9, 11, 13, 15, -21, -19, -17, -15, -15, -13, -11, -9
Offset: 0

Views

Author

John Tyler Rascoe, Sep 23 2023

Keywords

Comments

For n in A014601 row n will contain all even numbers from 0 to A000217(n).
For n in A042963 row n will contain all odd numbers from 1 to A000217(n).

Examples

			Triangle begins:
        k=0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
  n=0:    0;
  n=1:   -1,  1;
  n=2:   -3, -1,  1,  3;
  n=3:   -6, -4, -2,  0,  0,  2,  4,  6;
  n=4:  -10, -8, -6, -4, -4, -2,  0,  2, -2,  0,  2,  4,  4,  6,  8, 10;
  ...
The binary tree starts with root 0 in row n = 0. For rows n < 2, k = 0.
In row n = 3, the parent node -3 has left child -6 = 2*(-3) - (-1) - 1.
The tree begins:
row
[n]
[0]                   ______0______
                     /             \
[1]              __-1__           __1__
                /      \         /     \
[2]           -3       -1       1       3
              / \      / \     / \     / \
[3]         -6  -4   -2   0   0   2   4   6
.
		

Crossrefs

Programs

  • PARI
    T(n,k) = sum(i=0,n-1, if(bittest(k,i), i+1, -(i+1))); \\ Kevin Ryde, Nov 14 2023
  • Python
    def A365968(n, k):
        b, x = bin(k)[2:].zfill(n), 0
        for i in range(0, n):
            x += (-1)**(int(b[n-(i+1)])+1)*(i+1)
        return(x) # John Tyler Rascoe, Nov 12 2023
    

Formula

T(n,k) = - Sum_{i=0..n-1} (i+1)*(-1)^b[i] where the binary expansion of k is k = Sum_{i=0..n-1} b[i]*2^i. - Kevin Ryde, Nov 14 2023

A367076 Irregular triangle read by rows: T(n,k) (0 <= n, 0 <= k < 2^n). T(n,k) = -Sum_{i=0..k} A365968(n,i).

Original entry on oeis.org

0, 1, 0, 3, 4, 3, 0, 6, 10, 12, 12, 12, 10, 6, 0, 10, 18, 24, 28, 32, 34, 34, 32, 34, 34, 32, 28, 24, 18, 10, 0, 15, 28, 39, 48, 57, 64, 69, 72, 79, 84, 87, 88, 89, 88, 85, 80, 85, 88, 89, 88, 87, 84, 79, 72, 69, 64, 57, 48, 39, 28, 15, 0, 21, 40, 57, 72, 87
Offset: 0

Views

Author

John Tyler Rascoe, Nov 05 2023

Keywords

Examples

			Triangle begins:
    k=0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
n=0:  0;
n=1:  1,  0;
n=2:  3,  4,  3,  0;
n=3:  6, 10, 12, 12, 12, 10,  6,  0;
n=4; 10, 18, 24, 28, 32, 34, 34, 32, 34, 34, 32, 28, 24, 18, 10,  0;
		

Crossrefs

Cf. A000217 (column k=0), A028552 (column k=1), A192021 (row sums).

Programs

  • Mathematica
    nmax=10; row[n_]:=Join[CoefficientList[Series[1/(1-x)*Sum[ i/(1+x^2^(i-1))*Product[1+x^2^j,{j,0,i-2}],{i,n}],{x,0,2^n-1}],x],{0}]; Array[row,6,0] (* Stefano Spezia, Dec 23 2023 *)
  • Python
    def row_gen(n):
        x = 0
        for k in range(2**n):
            b = bin(k)[2:].zfill(n)
            x += sum((-1)**(int(b[n-i])+1)*i for i in range(1,n+1))
            yield(-x)
    def A367076_row_n(n): return(list(row_gen(n)))

Formula

T(n,k) = Sum_{i=0..n} abs(k + 1 - (2^i) * round((k+1)/2^i)) * i.
G.f. for n-th row: 1/(1-x) * Sum_{i=1..n} (i/(1+x^2^(i-1)) * Product_{j=0..i-2} 1 + x^2^j).
Showing 1-2 of 2 results.