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.

Showing 1-2 of 2 results.

A214870 Natural numbers placed in table T(n,k) layer by layer. The order of placement: at the beginning filled odd places of layer clockwise, next - even places counterclockwise. T(n,k) read by antidiagonals.

Original entry on oeis.org

1, 2, 3, 5, 4, 7, 10, 9, 8, 13, 17, 16, 6, 14, 21, 26, 25, 11, 12, 22, 31, 37, 36, 18, 15, 20, 32, 43, 50, 49, 27, 24, 23, 30, 44, 57, 65, 64, 38, 35, 19, 33, 42, 58, 73, 82, 81, 51, 48, 28, 29, 45, 56, 74, 91, 101, 100, 66, 63, 39, 34, 41, 59, 72, 92, 111
Offset: 1

Views

Author

Boris Putievskiy, Mar 11 2013

Keywords

Comments

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.
Layer is pair of sides of square from T(1,n) to T(n,n) and from T(n,n) to T(n,1).
Enumeration table T(n,k) layer by layer. The order of the list:
T(1,1)=1;
T(1,2), T(2,1), T(2,2);
. . .
T(1,n), T(3,n), ... T(n,3), T(n,1); T(n,2), T(n,4), ... T(4,n), T(2,n);
. . .

Examples

			The start of the sequence as table:
   1   2   5  10  17  26 ...
   3   4   9  16  25  36 ...
   7   8   6  11  18  27 ...
  13  14  12  15  24  35 ...
  21  22  20  23  19  28 ...
  31  32  30  33  29  34 ...
  ...
The start of the sequence as triangle array read by rows:
   1;
   2,  3;
   5,  4,  7;
  10,  9,  8, 13;
  17, 16,  6, 14, 21;
  26, 25, 11, 12, 22, 31;
  ...
		

Crossrefs

Programs

  • Python
    t=int((math.sqrt(8*n-7) - 1)/ 2)
    i=n-t*(t+1)/2
    j=(t*t+3*t+4)/2-n
    if i > j:
       result=i*i-i+(j%2)*(2-(j+1)/2)+((j+1)%2)*(j/2+1)
    else:
       result=j*j-2*(i%2)*j + (i%2)*((i+1)/2+1) + ((i+1)%2)*(-i/2+1)

Formula

As table
T(n,k) = k*k-2*(n mod 2)*k+(n mod 2)*((n+1)/2+1)+((n+1) mod 2)*(-n/2+1), if n<=k;
T(n,k) = n*n-n+(k mod 2)*(2-(k+1)/2)+((k+1) mod 2)*(k/2+1), if n>k.
As linear sequence
a(n) = j*j-2*(i mod 2)*j+(i mod 2)*((i+1)/2+1)+((i+1) mod 2)*(-i/2+1), if i<=j;
a(n) = i*i-i+(j mod 2)*(2-(j+1)/2)+((j+1) mod 2)*(j/2+1), if i>j; where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2).

A214871 Natural numbers placed in table T(n,k) layer by layer. The order of placement - T(n,n), T(1,n), T(n,1), T(2,n), T(n,2),...T(n-1,n), T(n,n-1). Table T(n,k) read by antidiagonals.

Original entry on oeis.org

1, 3, 4, 6, 2, 7, 11, 8, 9, 12, 18, 13, 5, 14, 19, 27, 20, 15, 16, 21, 28, 38, 29, 22, 10, 23, 30, 39, 51, 40, 31, 24, 25, 32, 41, 52, 66, 53, 42, 33, 17, 34, 43, 54, 67, 83, 68, 55, 44, 35, 36, 45, 56, 69, 84, 102, 85, 70, 57, 46, 26, 47, 58, 71, 86, 103, 123
Offset: 1

Views

Author

Boris Putievskiy, Mar 11 2013

Keywords

Comments

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.
Layer is pair of sides of square from T(1,n) to T(n,n) and from T(n,n) to T(n,1).
Enumeration table T(n,k) layer by layer. The order of the list:
T(1,1)=1;
T(2,2), T(1,2), T(2,1);
. . .
T(n,n), T(1,n), T(n,1), T(2,n), T(n,2),...T(n-1,n), T(n,n-1);
. . .

Examples

			The start of the sequence as table:
  1....3...6..11..18..27...
  4....2...8..13..20..29...
  7....9...5..15..22..31...
  12..14..16..10..24..33...
  19..21..23..25..17..35...
  28..30..32..34..36..26...
  . . .
The start of the sequence as triangle array read by rows:
  1;
  3,4;
  6,2,7;
  11,8,9,12;
  18,13,5,14,19;
  27,20,15,16,21,28;
  . . .
		

Crossrefs

Cf. A060734, A060736, A185725, A213921, A213922; table T(n,k) contains: in rows A059100, A087475, A114949, A189833, A114948, A114962; in columns A117950, A117951, A117619, A189834, A189836; the main diagonal is A002522.

Programs

  • Python
    t=int((math.sqrt(8*n-7) - 1)/ 2)
    i=n-t*(t+1)/2
    j=(t*t+3*t+4)/2-n
    if i == j:
       result=(i-1)**2+1
    if i > j:
       result=(i-1)**2+2*j+1
    if i < j:
       result=(j-1)**2+2*i

Formula

As table
T(n,k) = (n-1)^2+1, if n=k;
T(n,k) = (n-1)^2+2*k+1, if n>k;
T(n,k) = (k-1)^2+2*n, if n
As linear sequence
a(n) = (i-1)^2+1, if i=j;
a(n) = (i-1)^2+2*j+1, if i>j;
a(n) = (j-1)^2+2*i, if i>j; where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2).
Showing 1-2 of 2 results.