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.

A049581 Table T(n,k) = |n-k| read by antidiagonals (n >= 0, k >= 0).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Commutative non-associative operator with identity 0. T(nx,kx) = x T(n,k). A multiplicative analog is A089913. - Marc LeBrun, Nov 14 2003
For the characteristic polynomial of the n X n matrix M_n with entries M_n(i, j) = |i-j| see A203993. - Wolfdieter Lang, Feb 04 2018
For the determinant of the n X n matrix M_n with entries M_n(i, j) = |i-j| see A085750. - Bernard Schott, May 13 2020
a(n) = 0 iff n = 4 times triangular number (A046092). - Bernard Schott, May 13 2020

Examples

			Displayed as a triangle t(n, k):
  n\k   0 1 2 3 4 5 6 7 8 9 10 ...
  0:    0
  1:    1 1
  2:    2 0 2
  3:    3 1 1 3
  4:    4 2 0 2 4
  5:    5 3 1 1 3 5
  6:    6 4 2 0 2 4 6
  7:    7 5 3 1 1 3 5 7
  8:    8 6 4 2 0 2 4 6 8
  9:    9 7 5 3 1 1 3 5 7 9
  10:  10 8 6 4 2 0 2 4 6 8 10
... reformatted by _Wolfdieter Lang_, Feb 04 2018
Displayed as a table:
  0 1 2 3 4 5 6 ...
  1 0 1 2 3 4 5 ...
  2 1 0 1 2 3 4 ...
  3 2 1 0 1 2 3 ...
  4 3 2 1 0 1 2 ...
  5 4 3 2 1 0 1 ...
  6 5 4 3 2 1 0 ...
  ...
		

Crossrefs

Cf. A089913. Apart from signs, same as A114327. A203993.

Programs

  • GAP
    a := Flat(List([0..12],n->List([0..n],k->Maximum(k,n-k)-Minimum(k,n-k)))); # Muniru A Asiru, Jan 26 2018
    
  • Magma
    [[Abs(n-2*k): k in [0..n]]: n in [0..12]]; // G. C. Greubel, Jun 07 2019
    
  • Maple
    seq(seq(abs(n-2*k),k=0..n),n=0..12); # Robert Israel, Sep 30 2015
  • Mathematica
    Table[Abs[(n-k) -k], {n,0,12}, {k,0,n}]//Flatten (* Michael De Vlieger, Sep 29 2015 *)
    Table[Join[Range[n,0,-2],Range[If[EvenQ[n],2,1],n,2]],{n,0,12}]//Flatten (* Harvey P. Dale, Sep 18 2023 *)
  • PARI
    a(n) = abs(2*(n+1)-binomial((sqrtint(8*(n+1))+1)\2, 2)-(binomial(1+floor(1/2 + sqrt(2*(n+1))), 2))-1);
    vector(100, n , a(n-1)) \\ Altug Alkan, Sep 29 2015
    
  • PARI
    {t(n,k) = abs(n-2*k)}; \\ G. C. Greubel, Jun 07 2019
    
  • Python
    from math import isqrt
    def A049581(n): return abs((k:=n+1<<1)-((m:=isqrt(k))+(k>m*(m+1)))**2-1) # Chai Wah Wu, Nov 09 2024
  • Sage
    [[abs(n-2*k) for k in (0..n)] for n in (0..12)] # G. C. Greubel, Jun 07 2019
    

Formula

G.f.: (x + y - 4*x*y + x^2*y + x*y^2)/((1-x)^2*(1-y)^2*(1-x*y)) = (x/(1-x)^2 + y/(1-y)^2)/(1-x*y). T(n,0) = T(0,n) = n; T(n+1,k+1) = T(n,k). - Franklin T. Adams-Watters, Feb 06 2006
a(n) = |A002260(n+1)-A004736(n+1)| or a(n) = |((n+1)-t*(t+1)/2) - ((t*t+3*t+4)/2-(n+1))| where t = floor((-1+sqrt(8*(n+1)-7))/2). - Boris Putievskiy, Dec 24 2012; corrected by Altug Alkan, Sep 30 2015
From Robert Israel, Sep 30 2015: (Start)
If b(n) = a(n+1) - 2*a(n) + a(n-1), then for n >= 3 we have
b(n) = -1 if n = (j^2+5j+4)/2 for some integer j >= 1
b(n) = -3 if n = (j^2+5j+6)/2 for some integer j >= 0
b(n) = 4 if n = 2j^2 + 6j + 4 for some integer j >= 0
b(n) = 2 if n = 2j^2 + 8j + 7 or 2j^2 + 8j + 8 for some integer j >= 0
b(n) = 0 otherwise. (End)
Triangle t(n,k) = max(k, n-k) - min(k, n-k). - Peter Luschny, Jan 26 2018
Triangle t(n, k) = |n - 2*k| for n >= 0, k = 0..n. See the Maple and Mathematica programs. Hence t(n, k)= t(n, n-k). - Wolfdieter Lang, Feb 04 2018
a(n) = |t^2 - 2*n - 1|, where t = floor(sqrt(2*n+1) + 1/2). - Ridouane Oudra, Jun 07 2019; Dec 11 2020
As a rectangle, T(n,k) = |n-k| = max(n,k) - min(n,k). - Clark Kimberling, May 11 2020