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.

A185180 Enumeration table T(n,k) by antidiagonals. The order of the list is symmetrical movement from center to edges diagonal.

Original entry on oeis.org

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

Views

Author

Boris Putievskiy, Dec 26 2012

Keywords

Comments

The natural numbers are grouped in chunks of 1, 2, 3, 4,... as (1), (2,3), (4,5,6), (7,8,9,10), etc and each group fills a diagonal in the table. The smallest number in a group is in A000124, the largest in A000217. Numbers in a group are placed on free spots as close as possible to the middle of the diagonal, given preference to the smaller row numbers in the table if there is a draw.
The resulting array is apparently a transposed version of A064789 (if this was also written as an array).
The order of the list table T(n,k):
if n is odd:
T (floor(n+1)/2,floor(n+1)/2), T(floor(n+1)/2-1,floor(n+1)/2+1), T(floor(n+1)/2+1,floor(n+1)/2-1),...T(1,n), T(n,1)
if n is even:
T(floor(n+1)/2-1,floor(n+1)/2+1), T(floor(n+1)/2+1,floor(n+1)/2-1),...T(1,n), T(n,1).
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.

Examples

			The start of the sequence as table:
  1....2....5....9...14...20...27 ...
  3....4....7...12...18...25...33 ...
  6....8...11...16...23...31...40 ...
  10..13...17...22...29...38...48 ...
  15..19...24...30...37...46...57 ...
  21..26...32...39...47...56...67 ...
  28..34...41...49...58...68...79 ...
  ...
The start of the sequence as triangle array read by rows:
  1;
  2,   3;
  5,   4,  6;
  9,   7,  8, 10;
  14, 12, 11, 13, 15;
  20, 18, 16, 17, 19, 21;
  27, 25, 23, 22, 24, 26, 28;
. . .
Row number k (k > 1) of the triangle contains a permutation of the set of k numbers from (k^2-k+2)/2, (k^2-k+2)/2 + 1 ,...up to (k^2+k-2)/2 + 1, namely (k^2+k-2)/2, (k^2+k-2)/2 -2,...,(k^2-k+2)/2, (k^2-k+2)/2 + 2,..., (k^2+k-2)/2-1, (k^2+k-2)/2+1.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[{i, j, t}, i = n - t(t+1)/2; j = (t^2 + 3t + 4)/2 - n; t = Floor[(-1 + Sqrt[8n - 7])/2]; If[j <= i, (i(i+1) + (j-1)(j + 2i - 4))/2, (i(i+1) + (j-1)(j + 2i - 4))/2 + 2(j-i) - 1]];
    Array[a, 68] (* Jean-François Alcover, Nov 21 2018, from Python *)
  • 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 j<=i:
       m=(i*(i+1) + (j-1)*(j+2*i-4))/2
    else:
       m=(i*(i+1) + (j-1)*(j+2*i-4))/2 +2*(j-i)-1

Formula

a(n) = (i*(i+1) + (j-1)*(j+2*i-4))/2, if j<=i, a(n)=(i*(i+1) + (j-1)*(j+2*i-4))/2 +2*(j-i)-1, if j>i, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor[(-1+sqrt(8*n-7))/2].