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-4 of 4 results.

A060734 Natural numbers written as a square array ending in last row from left to right and rightmost column from bottom to top are read by antidiagonals downwards.

Original entry on oeis.org

1, 4, 2, 9, 3, 5, 16, 8, 6, 10, 25, 15, 7, 11, 17, 36, 24, 14, 12, 18, 26, 49, 35, 23, 13, 19, 27, 37, 64, 48, 34, 22, 20, 28, 38, 50, 81, 63, 47, 33, 21, 29, 39, 51, 65, 100, 80, 62, 46, 32, 30, 40, 52, 66, 82, 121, 99, 79, 61, 45, 31, 41, 53, 67, 83, 101
Offset: 1

Views

Author

Frank Ellermann, Apr 23 2001

Keywords

Comments

A simple permutation of natural numbers.
Parity of the sequence is given by A057211 (n-th run has length n). - Jeremy Gardiner, Dec 26 2008
The square with corners T(1,1)=1 and T(n,n)=n^2-n+1 is occupied by the numbers 1,2,...,n^2. - Clark Kimberling, Feb 01 2011
a(n) is pairing function - function that reversibly maps Z^{+} x Z^{+} onto Z^{+}, where Z^{+} - the set of integer positive numbers. - Boris Putievskiy, Dec 17 2012

Examples

			Northwest corner:
.1  4  9 16 ..  => a(1) =  1
.2  3  8 15 ..  => a(2) =  4, a(3) = 2
.5  6  7 14 ..  => a(4) =  9, a(5) = 3, a(6) = 5
10 11 12 13 ..  => a(7) = 16, a(8) = 8, a(9) = 6, a(10)=10
		

Crossrefs

Cf. A060736. Inverse: A064790.

Programs

  • Maple
    T:= (n,k)-> `if`(n<=k, k^2-n+1, (n-1)^2+k):
    seq(seq(T(n, d-n), n=1..d-1), d=2..15);
  • Mathematica
    f[n_, k_]:=k^2-n+1/; k>=n;
    f[n_, k_]:=(n-1)^2+k/; kClark Kimberling, Feb 01 2011 *)

Formula

T(n,k) = (n-1)^2+k, T(k, n)=n^2+1-k, 1 <= k <= n.
From Clark Kimberling, Feb 01 2011: (Start)
T(1,k) = k^2 (A000290).
T(n,n) = n^2-n+1 (A002061).
T(n,1) = (n-1)^2+1 (A002522). (End)

Extensions

Corrected by Jeremy Gardiner, Dec 26 2008

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].

A194280 Inverse permutation to A081344.

Original entry on oeis.org

1, 2, 5, 3, 6, 9, 13, 8, 4, 7, 12, 18, 25, 19, 14, 10, 15, 20, 26, 33, 41, 32, 24, 17, 11, 16, 23, 31, 40, 50, 61, 51, 42, 34, 27, 21, 28, 35, 43, 52, 62, 73, 85, 72, 60, 49, 39, 30, 22, 29, 38, 48, 59, 71, 84, 98, 113
Offset: 1

Views

Author

Boris Putievskiy, Dec 23 2012

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.
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 sequence is A188568 as table read layer by layer clockwise.
The same table A188568 read by boustrophedon ("ox-plowing") method - layer clockwise, layer counterclockwise and so on - is A064790. - Boris Putievskiy, Mar 14 2013

Examples

			From _Boris Putievskiy_, Mar 14 2013: (Start)
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,5,3;
  6,9,13,8,4;
  7,12,18,25,19,14,10;
  15,20,26,33,41,32,24,17,11;
  16,23,31,40,50,61,51,42,34,27,21;
  28,35,43,52,62,73,85,72,60,49,39,30,22;
  ...
Row number r contains 2*r-1 numbers. (End)
		

Crossrefs

Programs

  • Python
    t=int(math.sqrt(n-1))+1
    i=(t % 2)*min(t,n-(t-1)**2) + ((t+1) % 2)*min(t,t**2-n+1)
    j=(t % 2)*min(t,t**2-n+1) + ((t+1) % 2)*min(t,n-(t-1)**2)
    m=(i+j-1)*(i+j-2)/2+j

Formula

a(n) = (i+j-1)*(i+j-2)/2+j, where
i = mod(t;2)*min{t; n - (t - 1)^2} + mod(t + 1; 2)*min{t; t^2 - n + 1}
j = mod(t;2)*min{t; t^2 - n + 1} + mod(t + 1; 2)*min{t; n - (t - 1)^2},
t = int(math.sqrt(n-1))+1.

A064788 Inverse permutation to A060736.

Original entry on oeis.org

1, 2, 5, 3, 4, 8, 13, 9, 6, 7, 12, 18, 25, 19, 14, 10, 11, 17, 24, 32, 41, 33, 26, 20, 15, 16, 23, 31, 40, 50, 61, 51, 42, 34, 27, 21, 22, 30, 39, 49, 60, 72, 85, 73, 62, 52, 43, 35, 28, 29, 38, 48, 59, 71, 84, 98, 113, 99, 86, 74, 63, 53, 44, 36, 37, 47, 58, 70, 83, 97, 112
Offset: 1

Views

Author

N. J. A. Sloane, Oct 20 2001

Keywords

Crossrefs

Programs

Formula

a(n) = (i+j-1)*(i+j-2)/2+j, where i=min(t; t^2-n+1), j=min(t; n-(t-1)^2), t=floor(sqrt(n-1))+1. - Boris Putievskiy, Dec 24 2012

Extensions

More terms from David Wasserman, Jan 15 2002
Showing 1-4 of 4 results.