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.

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