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.

A344839 Square array T(n, k), n, k >= 0, read by antidiagonals; T(n, k) = abs(n * 2^max(0, w(k)-w(n)) - k * 2^max(0, w(n)-w(k))) (where w = A070939).

Original entry on oeis.org

0, 1, 1, 2, 0, 2, 3, 0, 0, 3, 4, 1, 0, 1, 4, 5, 0, 1, 1, 0, 5, 6, 1, 0, 0, 0, 1, 6, 7, 2, 1, 2, 2, 1, 2, 7, 8, 3, 2, 1, 0, 1, 2, 3, 8, 9, 0, 3, 0, 1, 1, 0, 3, 0, 9, 10, 1, 0, 1, 2, 0, 2, 1, 0, 1, 10, 11, 2, 1, 4, 3, 1, 1, 3, 4, 1, 2, 11, 12, 3, 2, 3, 0, 2, 0, 2, 0, 3, 2, 3, 12
Offset: 0

Views

Author

Rémy Sigrist, May 29 2021

Keywords

Comments

In other words, we right pad the binary expansion of the lesser of n and k with zeros (provided it is positive) so that both numbers have the same number of binary digits, and then take the absolute difference.

Examples

			Array T(n, k) begins:
  n\k|   0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
  ---+-------------------------------------------------------
    0|   0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
    1|   1  0  0  1  0  1  2  3  0  1   2   3   4   5   6   7
    2|   2  0  0  1  0  1  2  3  0  1   2   3   4   5   6   7
    3|   3  1  1  0  2  1  0  1  4  3   2   1   0   1   2   3
    4|   4  0  0  2  0  1  2  3  0  1   2   3   4   5   6   7
    5|   5  1  1  1  1  0  1  2  2  1   0   1   2   3   4   5
    6|   6  2  2  0  2  1  0  1  4  3   2   1   0   1   2   3
    7|   7  3  3  1  3  2  1  0  6  5   4   3   2   1   0   1
    8|   8  0  0  4  0  2  4  6  0  1   2   3   4   5   6   7
    9|   9  1  1  3  1  1  3  5  1  0   1   2   3   4   5   6
   10|  10  2  2  2  2  0  2  4  2  1   0   1   2   3   4   5
   11|  11  3  3  1  3  1  1  3  3  2   1   0   1   2   3   4
   12|  12  4  4  0  4  2  0  2  4  3   2   1   0   1   2   3
   13|  13  5  5  1  5  3  1  1  5  4   3   2   1   0   1   2
   14|  14  6  6  2  6  4  2  0  6  5   4   3   2   1   0   1
   15|  15  7  7  3  7  5  3  1  7  6   5   4   3   2   1   0
		

Crossrefs

Cf. A344834 (AND), A344835 (OR), A344836 (XOR), A344837 (min), A344838 (max).

Programs

  • PARI
    T(n,k,op=(x,y)->abs(x-y),w=m->#binary(m)) = { op(n*2^max(0, w(k)-w(n)), k*2^max(0, w(n)-w(k))) }

Formula

T(n, k) = T(k, n).
T(n, n) = 0.
T(n, 0) = n.
T(n, 1) = A053645(n) for any n > 0.