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.

A188568 Enumeration table T(n,k) by descending antidiagonals. The order of the list - if n is odd: T(n,1), T(2,n-1), T(n-2,3), ..., T(n-1,2), T(1,n); if n is even: T(1,n), T(n-1,2), T(3,n-2), ..., T(2,n-1), T(n,1).

Original entry on oeis.org

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

Views

Author

Boris Putievskiy, Dec 27 2012

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.
Call a "layer" a pair of sides of square from T(1,n) to T(n,n) and from T(n,n) to T(n,1). This table read layer by layer clockwise is A194280. This table read by boustrophedonic ("ox-plowing") method - layer clockwise, layer counterclockwise and so on - is A064790. - Boris Putievskiy, Mar 14 2013

Examples

			The start of the sequence as table:
   1,  2,  6,  7, 15, 16, 28, ...
   3,  5,  9, 12, 20, 23, 35, ...
   4,  8, 13, 18, 26, 31, 43, ...
  10, 14, 19, 25, 33, 40, 52, ...
  11, 17, 24, 32, 41, 50, 62, ...
  21, 27, 34, 42, 51, 61, 73, ...
  22, 30, 39, 49, 60, 72, 85, ...
  ...
The start of the sequence as triangular array read by rows:
   1;
   2,  3;
   6,  5,  4;
   7,  9,  8, 10;
  15, 12, 13, 14, 11;
  16, 20, 18, 19, 17, 21;
  28, 23, 26, 25, 24, 27, 22;
  ...
Row number k contains permutation of the k numbers:
{ (k^2-k+2)/2, (k^2-k+2)/2 + 1, ..., (k^2+k-2)/2 + 1 }.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[{t, i, j},
    t = Floor[(Sqrt[8n-7]-1)/2];
    i = n-t(t+1)/2;
    j = (t^2+3t+4)/2-n;
    ((i+j-1)(i+j-2) + ((-1)^Max[i,j]+1)i - ((-1)^Max[i,j]-1)j)/2];
    Array[a, 55] (* Jean-François Alcover, Jan 26 2019 *)
  • Python
    t=int((math.sqrt(8*n-7) - 1)/ 2)
    i=n-t*(t+1)/2
    j=(t*t+3*t+4)/2-n
    m=((i+j-1)*(i+j-2)+((-1)**max(i,j)+1)*i-((-1)**max(i,j)-1)*j)/2

Formula

a(n) = ((i+j-1)*(i+j-2)+((-1)^max(i,j)+1)*i-((-1)^max(i,j)-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].