OFFSET
1,3
COMMENTS
The triangle equals A158946 with the first column removed. - Georg Fischer, Jul 26 2023
LINKS
Boris Putievskiy, Rows n = 1..140 of triangle, flattened
Boris Putievskiy, Transformations Integer Sequences And Pairing Functions, arXiv:1212.2732 [math.CO], 2012.
Eric Weisstein's World of Mathematics, Pairing functions
FORMULA
a(n) = |A128180(n)|.
a(n) = floor((t+2)/2) + floor(i/2)*(-1)^(i+t+1), where t=floor((-1+sqrt(8*n-7))/2), i=n-t*(t+1)/2.
T(r,2s)=s, T(r,2s-1)= r+s-1.(When read as table T(r,s) by antidiagonals.)
T(n,k) = ceiling((n + (-1)^(n-k)*k)/2) = (n+k)/2 if n-k even, otherwise (n-k+1)/2. - M. F. Hasler, May 30 2020
EXAMPLE
The start of the sequence as table T(r,s) r,s >0 read by antidiagonals:
1...1...2...2...3...3...4...4...
2...1...3...2...4...3...5...4...
3...1...4...2...5...3...6...4...
4...1...5...2...6...3...7...4...
5...1...6...2...7...3...8...4...
6...1...7...2...8...3...9...4...
7...1...8...2...9...3..10...4...
...
The start of the sequence as triangle array read by rows:
1;
1, 2;
2, 1, 3;
2, 3, 1, 4;
3, 2, 4, 1, 5;
3, 4, 2, 5, 1, 6;
4, 3, 5, 2, 6, 1, 7;
4, 5, 3, 6, 2, 7, 1, 8;
...
Row number r contains permutation numbers form 1 to r.
If r is odd (r+1)/2, (r+1)/2-1, (r+1)/2+1,...r-1, 1, r.
If r is even r/2, r/2+1, r/2-1, ... r-1, 1, r.
MATHEMATICA
T[n_, k_] := Abs[(2*k - 1 + (-1)^(n - k)*(2*n + 1))/4];
Table[T[n, k], {n, 1, 15}, {k, 1, n}] // Flatten (* Jean-François Alcover, Jun 14 2018, after Andrew Howroyd *)
PROG
(PARI) T(n, k)=abs((2*k-1+(-1)^(n-k)*(2*n+1))/4) \\ Andrew Howroyd, Dec 31 2017
(Python) # Edited by M. F. Hasler, May 30 2020
def a(n):
t = int((math.sqrt(8*n-7) - 1)/2);
i = n-t*(t+1)/2;
return int(t/2)+1+int(i/2)*(-1)**(i+t+1)
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Boris Putievskiy, Jan 15 2013
EXTENSIONS
Data corrected by Andrew Howroyd, Dec 31 2017
STATUS
approved