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.

A218890 T(n,k) = ((n + k - 1)*(n + k - 2) - (-1 + (-1)^floor((n + k)/2))*n + (1 +(-1)^floor((n + k)/2))*k)/2; n , k > 0, read by antidiagonals.

Original entry on oeis.org

1, 2, 3, 6, 5, 4, 10, 9, 8, 7, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 28, 27, 26, 25, 24, 23, 22, 36, 35, 34, 33, 32, 31, 30, 29, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 78
Offset: 1

Views

Author

Boris Putievskiy, Feb 19 2013

Keywords

Comments

Self-inverse permutation of the natural numbers.
a(n) is a pairing function: a function that reversibly maps Z^{+} x Z^{+} onto Z^{+}, where Z^{+} is the set of integer positive numbers.
In general, let m be natural number. Natural numbers placed in table T(n,k) by antidiagonals. The order of placement - at the beginning m antidiagonals downwards, next m antidiagonals upwards and so on. T(n,k) read by antidiagonals downwards.
For m = 1 the result is A056011. This sequence is result for m = 2.
A056023 is result for m = 1 and the changed order of placement - at the beginning m antidiagonals upwards, next m antidiagonals downwards and so on.

Examples

			The start of the sequence as table.  The direction of the placement denotes by ">" and  "v".
  v...v          v...v
..1...2...6..10..11..16..28..36...
..3...5...9..12..17..27..35..38...
> 4...8..13..18..26..34..39..48...
> 7..14..19..25..33..40..49..63...
.15..20..24..32..41..50..62..74...
.21..23..31..42..51..61..73..84...
>22..30..43..52..60..72..85..98...
>29..44..53..59..71..86..99.113...
  . . .
The start of the sequence as triangle array read by rows:
   1;
   2,  3;
   6,  5,  4;
  10,  9,  8,  7;
  11, 12, 13, 14, 15;
  16, 17, 18, 19, 20, 21;
  28, 27, 26, 25, 24, 23, 22;
  36, 35, 34, 33, 32, 31, 30, 29;
  ...
Row r consists of r consecutive numbers from r*r/2 - r/2 + 1 to r*r/2 + r.
If r congruent to 1 or 2 mod 4 rows are increasing.
If r congruent to 0 or 3 mod 4 rows are decreasing.
		

Crossrefs

Programs

  • Maple
    T:=(n,k)->((n+k-1)*(n+k-2)-(-1+(-1)^floor((n+k)/2))*n+(1+(-1)^floor((n+k)/2))*k)/2: seq(seq(T(k,n-k),k=1..n-1),n=1..13); # Muniru A Asiru, Dec 13 2018
  • Mathematica
    T[n_, k_] := ((n+k-1)(n+k-2) - (-1 + (-1)^Floor[(n+k)/2])n + (1 + (-1)^Floor[(n+k)/2]) k)/2;
    Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Dec 06 2018 *)
  • Maxima
    T(n,k) = ((n + k - 1)*(n + k - 2) - (-1 + (-1)^floor((n + k)/2))*n + (1 +(-1)^floor((n + k)/2))*k)/2$
    create_list(T(k, n - k), n, 1, 12, k, 1, n - 1); /* Franck Maminirina Ramaharo, Dec 13 2018 */
  • Python
    t=int((math.sqrt(8*n-7) - 1)/ 2)
    i=n-t*(t+1)/2
    j=(t*t+3*t+4)/2-n
    z=i+j
    result=((z-1)*(z-2)-(-1+(-1)**int(z/2))*i+(1+(-1)**int(z/2))*j)/2
    

Formula

For the general case.
As a table
T(n,k) = ((n + k - 1)*(n + k - 2) - (-1 + (-1)^floor((n + k + m - 2)/m))*n + (1 +(-1)^floor((n + k + m - 2)/m))*k)/2.
As linear sequence
a(n) = ((z - 1)*(z - 2) - (-1 + (-1)^floor((z + m - 2)/m))*i + (1 + (-1)^floor((z + m - 2)/m))*j)/2, where i = n - t*(t + 1)/2, j = (t*t + 3*t + 4)/2 - n, t = floor((-1 + sqrt(8*n - 7))/2), z = i + j.
If we change the order of placement - m antidiagonals upwards, m antidiagonals downwards and so on.
As a table
T(n,k) = ((n + k - 1)*(n + k - 2) - (-1 + (-1)^(floor((n + k + m - 2)/m) + 1))*n + (1 + (-1)^(floor((n + k + m - 2)/m) + 1))*k)/2.
As linear sequence
a(n) = ((z - 1)*(z - 2) - (-1 + (-1)^(floor((z + m - 2)/m) + 1))*i + (1 + (-1)^(floor((z + m - 2)/m) + 1))*j)/2, where i = n - t*(t + 1)/2, j = (t*t + 3*t + 4)/2 - n, t = floor((-1 + sqrt(8*n - 7))/2), z = i + j.
For this sequence.
As a table
T(n,k) = ((n + k - 1)*(n + k - 2) - (-1 +(-1)^floor((n + k)/2))*n + (1 + (-1)^floor((n + k)/2))*k)/2.
As linear sequence
a(n) = ((z - 1)*(z - 2) - (-1 + (-1)^floor(z/2))*i + (1 + (-1)^floor(z/2))*j)/2, where i = n - t*(t + 1)/2, j = (t*t + 3*t + 4)/2 - n, t = floor((-1 + sqrt(8*n - 7))/2), z = i + j.