login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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.
4
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,4
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).
LINKS
John Tyler Rascoe, Rows n = 0..12, flattened
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
EXAMPLE
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
.
PROG
(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
(PARI) T(n, k) = sum(i=0, n-1, if(bittest(k, i), i+1, -(i+1))); \\ Kevin Ryde, Nov 14 2023
CROSSREFS
KEYWORD
sign,tabf,look,easy
AUTHOR
John Tyler Rascoe, Sep 23 2023
STATUS
approved