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”).

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

%I #113 Nov 09 2024 18:08:33

%S 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,

%T 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,

%U 9,7,5,3,1,1,3,5,7,9,11,12,10,8,6,4,2,0,2,4,6,8,10,12

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

%C Commutative non-associative operator with identity 0. T(nx,kx) = x T(n,k). A multiplicative analog is A089913. - _Marc LeBrun_, Nov 14 2003

%C 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

%C 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

%C a(n) = 0 iff n = 4 times triangular number (A046092). - _Bernard Schott_, May 13 2020

%H Peter Kagey, <a href="/A049581/b049581.txt">Rows n = 0..125 of triangle, flattened</a>

%F G.f.: (x + y - 4xy + x^2y + xy^2)/((1-x)^2 (1-y)^2) (1-xy)) = (x/(1-x)^2 + y/(1-y)^2)/(1-xy). T(n,0) = T(0,n) = n; T(n+1,k+1) = T(n,k). - _Franklin T. Adams-Watters_, Feb 06 2006

%F 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

%F From _Robert Israel_, Sep 30 2015: (Start)

%F If b(n) = a(n+1) - 2*a(n) + a(n-1), then for n >= 3 we have

%F b(n) = -1 if n = (j^2+5j+4)/2 for some integer j >= 1

%F b(n) = -3 if n = (j^2+5j+6)/2 for some integer j >= 0

%F b(n) = 4 if n = 2j^2 + 6j + 4 for some integer j >= 0

%F b(n) = 2 if n = 2j^2 + 8j + 7 or 2j^2 + 8j + 8 for some integer j >= 0

%F b(n) = 0 otherwise. (End)

%F Triangle t(n,k) = max(k, n-k) - min(k, n-k). - _Peter Luschny_, Jan 26 2018

%F 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

%F a(n) = |t^2 - 2*n - 1|, where t = floor(sqrt(2*n+1) + 1/2). - _Ridouane Oudra_, Jun 07 2019; Dec 11 2020

%F As a rectangle, T(n,k) = |n-k| = max(n,k) - min(n,k). - _Clark Kimberling_, May 11 2020

%e Displayed as a triangle t(n, k):

%e n\k 0 1 2 3 4 5 6 7 8 9 10 ...

%e 0: 0

%e 1: 1 1

%e 2: 2 0 2

%e 3: 3 1 1 3

%e 4: 4 2 0 2 4

%e 5: 5 3 1 1 3 5

%e 6: 6 4 2 0 2 4 6

%e 7: 7 5 3 1 1 3 5 7

%e 8: 8 6 4 2 0 2 4 6 8

%e 9: 9 7 5 3 1 1 3 5 7 9

%e 10: 10 8 6 4 2 0 2 4 6 8 10

%e ... reformatted by _Wolfdieter Lang_, Feb 04 2018

%e Displayed as a table:

%e 0 1 2 3 4 5 6 ...

%e 1 0 1 2 3 4 5 ...

%e 2 1 0 1 2 3 4 ...

%e 3 2 1 0 1 2 3 ...

%e 4 3 2 1 0 1 2 ...

%e 5 4 3 2 1 0 1 ...

%e 6 5 4 3 2 1 0 ...

%e ...

%p seq(seq(abs(n-2*k),k=0..n),n=0..12); # _Robert Israel_, Sep 30 2015

%t Table[Abs[(n-k) -k], {n,0,12}, {k,0,n}]//Flatten (* _Michael De Vlieger_, Sep 29 2015 *)

%t Table[Join[Range[n,0,-2],Range[If[EvenQ[n],2,1],n,2]],{n,0,12}]//Flatten (* _Harvey P. Dale_, Sep 18 2023 *)

%o (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);

%o vector(100, n , a(n-1)) \\ _Altug Alkan_, Sep 29 2015

%o (PARI) {t(n,k) = abs(n-2*k)}; \\ _G. C. Greubel_, Jun 07 2019

%o (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

%o (Magma) [[Abs(n-2*k): k in [0..n]]: n in [0..12]]; // _G. C. Greubel_, Jun 07 2019

%o (Sage) [[abs(n-2*k) for k in (0..n)] for n in (0..12)] # _G. C. Greubel_, Jun 07 2019

%o (Python)

%o from math import isqrt

%o def A049581(n): return abs((k:=n+1<<1)-((m:=isqrt(k))+(k>m*(m+1)))**2-1) # _Chai Wah Wu_, Nov 09 2024

%Y Cf. A003989, A003990, A003991, A003056, A004247, A002260, A004736.

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

%K nonn,tabl,easy,nice

%O 0,4

%A _N. J. A. Sloane_