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

A209278 Second inverse function (numbers of rows) for pairing function A185180.

Original entry on oeis.org

1, 2, 1, 2, 3, 1, 3, 2, 4, 1, 3, 4, 2, 5, 1, 4, 3, 5, 2, 6, 1, 4, 5, 3, 6, 2, 7, 1, 5, 4, 6, 3, 7, 2, 8, 1, 5, 6, 4, 7, 3, 8, 2, 9, 1, 6, 5, 7, 4, 8, 3, 9, 2, 10, 1, 6, 7, 5, 8, 4, 9, 3, 10, 2, 11, 1
Offset: 1

Views

Author

Boris Putievskiy, Jan 15 2013

Keywords

Examples

			The start of the sequence as table T(r,s) r,s >0 read by antidiagonals:
1...2...2...3...3...4...4...5...
1...3...2...4...3...5...4...6...
1...4...2...5...3...6...4...7...
1...5...2...6...3...7...4...8...
1...6...2...7...3...8...4...9...
1...7...2...8...3...9...4..10...
1...8...2...9...3..10...4..11...
. . .
The start of the sequence as triangle array read by rows:
1;
2, 1;
2, 3, 1;
3, 2, 4, 1;
3, 4, 2, 5, 1;
4, 3, 5, 2, 6, 1;
4, 5, 3, 6, 2, 7, 1;
5, 4, 6, 3, 7, 2, 8, 1;
. . .
Row number r contains permutation numbers form 1 to r.
If r is odd (r+1)/2, (r+1)/2 +1, (r+1)/2 -1, ... 2, r, 1.
If r is even r/2 + 1, r/2, r/2 + 2, ...  2, r, 1.
		

Crossrefs

Programs

  • Mathematica
    T[r_, s_] := If[OddQ[s], (s+1)/2, r + s/2];
    Table[T[r-s+1, s], {r, 1, 11}, {s, r, 1, -1}] // Flatten (* Jean-François Alcover, Nov 19 2019 *)
  • PARI
    T(r,s)=s\2+if(bittest(s,0),1,r) \\ - M. F. Hasler, Jan 15 2013
  • Python
    t=int((math.sqrt(8*n-7) - 1)/ 2)
    i=n-t*(t+1)/2
    result=int((t+3)/2)+int(i/2)*(-1)**(i+t)
    

Formula

a(n) = floor((A003056(n)+3)/2) + floor(A002260(n)/2)*(-1)^(A002260(n)+A003056(n)).
a(n)= floor((t+3)/2)+ floor(i/2)*(-1)^(i+t),
where t=floor((-1+sqrt(8*n-7))/2), i=n-t*(t+1)/2.
T(r,2s-1)=s, T(r,2s)= r+s. (When read as square array by antidiagonals.)

A209279 First inverse function (numbers of rows) for pairing function A185180.

Original entry on oeis.org

1, 1, 2, 2, 1, 3, 2, 3, 1, 4, 3, 2, 4, 1, 5, 3, 4, 2, 5, 1, 6, 4, 3, 5, 2, 6, 1, 7, 4, 5, 3, 6, 2, 7, 1, 8, 5, 4, 6, 3, 7, 2, 8, 1, 9, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 6, 5, 7, 4, 8, 3, 9, 2, 10, 1, 11, 6, 7, 5, 8, 4, 9, 3, 10, 2, 11, 1, 12, 7, 6, 8, 5, 9, 4, 10, 3, 11, 2, 12, 1, 13
Offset: 1

Views

Author

Boris Putievskiy, Jan 15 2013

Keywords

Comments

The triangle equals A158946 with the first column removed. - Georg Fischer, Jul 26 2023

Examples

			The start of the sequence as table T(r,s) r,s >0 read by antidiagonals:
  1...1...2...2...3...3...4...4...
  2...1...3...2...4...3...5...4...
  3...1...4...2...5...3...6...4...
  4...1...5...2...6...3...7...4...
  5...1...6...2...7...3...8...4...
  6...1...7...2...8...3...9...4...
  7...1...8...2...9...3..10...4...
  ...
The start of the sequence as triangle array read by rows:
  1;
  1, 2;
  2, 1, 3;
  2, 3, 1, 4;
  3, 2, 4, 1, 5;
  3, 4, 2, 5, 1, 6;
  4, 3, 5, 2, 6, 1, 7;
  4, 5, 3, 6, 2, 7, 1, 8;
  ...
Row number r contains permutation numbers form 1 to r.
If r is odd (r+1)/2, (r+1)/2-1, (r+1)/2+1,...r-1, 1, r.
If r is even r/2, r/2+1, r/2-1, ... r-1, 1, r.
		

Crossrefs

Programs

  • Mathematica
    T[n_, k_] := Abs[(2*k - 1 + (-1)^(n - k)*(2*n + 1))/4];
    Table[T[n, k], {n, 1, 15}, {k, 1, n}] // Flatten (* Jean-François Alcover, Jun 14 2018, after Andrew Howroyd *)
  • PARI
    T(n, k)=abs((2*k-1+(-1)^(n-k)*(2*n+1))/4) \\ Andrew Howroyd, Dec 31 2017
    
  • Python
    # Edited by M. F. Hasler, May 30 2020
    def a(n):
       t = int((math.sqrt(8*n-7) - 1)/2);
       i = n-t*(t+1)/2;
       return int(t/2)+1+int(i/2)*(-1)**(i+t+1)

Formula

a(n) = floor((A003056(n)+2)/2)+ floor(A002260(n)/2)*(-1)^(A002260(n)+A003056(n)+1).
a(n) = |A128180(n)|.
a(n) = floor((t+2)/2) + floor(i/2)*(-1)^(i+t+1), where t=floor((-1+sqrt(8*n-7))/2), i=n-t*(t+1)/2.
T(r,2s)=s, T(r,2s-1)= r+s-1.(When read as table T(r,s) by antidiagonals.)
T(n,k) = ceiling((n + (-1)^(n-k)*k)/2) = (n+k)/2 if n-k even, otherwise (n-k+1)/2. - M. F. Hasler, May 30 2020

Extensions

Data corrected by Andrew Howroyd, Dec 31 2017

A209293 Inverse permutation of A185180.

Original entry on oeis.org

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

Views

Author

Boris Putievskiy, Jan 16 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.
Enumeration table T(n,k) by diagonals. The order of the list
if n is odd - T(n-1,2),T(n-3,4),...,T(2,n-1),T(1,n),T(3,n-2),...T(n,1).
if n is even - T(n-1,2),T(n-3,4),...,T(3,n-2),T(1,n),T(2,n-1),...T(n,1).
Table T(n,k) contains:
Column number 1 A000217,
column number 2 A000124,
column number 3 A000096,
column number 4 A152948,
column number 5 A034856,
column number 6 A152950,
column number 7 A055998.
Row number 1 A000982,
row number 2 A097063.

Examples

			The start of the sequence as table:
  1....2...5...8..13..18...25...32...41...
  3....4...9..12..19..24...33...40...51...
  6....7..14..17..26..31...42...49...62...
  10..11..20..23..34..39...52...59...74...
  15..16..27..30..43..48...63...70...87...
  21..22..35..38..53..58...75...82..101...
  28..29..44..47..64..69...88...95..116...
  36..37..54..57..76..81..102..109..132...
  45..46..65..68..89..94..117..124..149...
  . . .
The start of the sequence as triangle array read by rows:
  1;
  2,3;
  5,4,6;
  8,9,7,10;
  13,12,14,11,15;
  18,19,17,20,16,21;
  25,24,26,23,27,22,28;
  32,33,31,34,30,35,29,36;
  41,40,42,39,43,38,44,37,45;
  . . .
Row number r contains permutation from r numbers:
if r is odd  ceiling(r^2/2), ceiling(r^2/2)+1, ceiling(r^2/2)-1, ceiling(r^2/2)+2, ceiling(r^2/2)-2,...r*(r+1)/2;
if r is even ceiling(r^2/2), ceiling(r^2/2)-1, ceiling(r^2/2)+1, ceiling(r^2/2)-2, ceiling(r^2/2)+2,...r*(r+1)/2;
		

Crossrefs

Programs

  • Mathematica
    max = 10; row[n_] := Table[Ceiling[(n + k - 1)^2/2] + If[OddQ[k], 1, -1]*Floor[n/2], {k, 1, max}]; t = Table[row[n], {n, 1, max}]; Table[t[[n - k + 1, k]], {n, 1, max}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Jan 17 2013 *)
  • Python
    t=int((math.sqrt(8*n-7) - 1)/ 2)
    i=n-t*(t+1)/2
    j=(t*t+3*t+4)/2-n
    m1=int((i+j)/2)+int(i/2)*(-1)**(i+t+1)
    m2=int((i+j+1)/2)+int(i/2)*(-1)**(i+t)
    m=(m1+m2-1)*(m1+m2-2)/2+m1

Formula

As table T(n,k) read by antidiagonals
T(n,k) = n*n/2+4*(floor((k-1)/2)+1)*n+ceiling((k-1)^2/2), n,k > 0.
As linear sequence
a(n) = (m1+m2-1)*(m1+m2-2)/2+m1, where
m1 = int((i+j)/2)+int(i/2)*(-1)^(i+t+1),
m2 = int((i+j+1)/2)+int(i/2)*(-1)^(i+t),
t = int((math.sqrt(8*n-7) - 1)/ 2),
i = n-t*(t+1)/2,
j = (t*t+3*t+4)/2-n.

A214928 A209293 as table read layer by layer clockwise.

Original entry on oeis.org

1, 2, 4, 3, 5, 9, 14, 7, 6, 8, 12, 17, 23, 20, 11, 10, 13, 19, 26, 34, 43, 30, 27, 16, 15, 18, 24, 31, 39, 48, 58, 53, 38, 35, 22, 21, 25, 33, 42, 52, 63, 75, 88, 69, 64, 47, 44, 29, 28, 32, 40, 49, 59, 70, 82, 95, 109, 102, 81, 76, 57, 54, 37, 36, 41, 51, 62
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). The order of the list:
T(1,1)=1;
T(1,2), T(2,2), T(2,1);
. . .
T(1,n), T(2,n), ... T(n-1,n), T(n,n), T(n,n-1), ... T(n,1);
. . .

Examples

			The start of the sequence as table:
  1....2...5...8..13..18...
  3....4...9..12..19..24...
  6....7..14..17..26..31...
  10..11..20..23..34..39...
  15..16..27..30..43..48...
  21..22..35..38..53..58...
  . . .
The start of the sequence as triangle array read by rows:
  1;
  2,4,3;
  5,9,14,7,6;
  8,12,17,23,20,11,10;
  13,19,26,34,43,30,27,16,15;
  18,24,31,39,48,58,53,38,35,22,21;
  . . .
Row number r contains 2*r-1 numbers.
		

Crossrefs

Programs

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

Formula

As table
T(n,k) = n*n/2+4*(floor((k-1)/2)+1)*n+ceiling((k-1)^2/2), n,k > 0.
As linear sequence
a(n)= (m1+m2-1)*(m1+m2-2)/2+m1, where m1=floor((i+j)/2) + floor(i/2)*(-1)^(2*i+j-1), m2=int((i+j+1)/2)+int(i/2)*(-1)^(2*i+j-2), where i=min(t; n-(t-1)^2), j=min(t; t^2-n+1), t=floor(sqrt(n-1))+1.

A214929 A209293 as table read layer by layer - layer clockwise, layer counterclockwise and so on.

Original entry on oeis.org

1, 3, 4, 2, 5, 9, 14, 7, 6, 10, 11, 20, 23, 17, 12, 8, 13, 19, 26, 34, 43, 30, 27, 16, 15, 21, 22, 35, 38, 53, 58, 48, 39, 31, 24, 18, 25, 33, 42, 52, 63, 75, 88, 69, 64, 47, 44, 29, 28, 36, 37, 54, 57, 76, 81, 102, 109, 95, 82, 70, 59, 49, 40, 32, 41, 51, 62
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). Table read by boustrophedonic ("ox-plowing") method. Let m be natural number. The order of the list:
T(1,1)=1;
T(2,1), T(2,2), T(1,2);
. . .
T(1,2*m+1), T(2,2*m+1), ... T(2*m,2*m+1), T(2*m+1,2*m+1), T(2*m+1,2*m), ... T(2*m+1,1);
T(2*m,1), T(2*m,2), ... T(2*m,2*m-1), T(2*m,2*m), T(2*m-1,2*m), ... T(1,2*m);
. . .
The first row is layer read clockwise, the second row is layer counterclockwise.

Examples

			The start of the sequence as table:
  1....2...5...8..13..18...
  3....4...9..12..19..24...
  6....7..14..17..26..31...
  10..11..20..23..34..39...
  15..16..27..30..43..48...
  21..22..35..38..53..58...
  . . .
The start of the sequence as triangle array read by rows:
  1;
  3,4,2;
  5,9,14,7,6;
  10,11,20,23,17,12,8;
  13,19,26,34,43,30,27,16,15;
  21,22,35,38,53,58,48,39,31,24,18;
  . . .
Row number r contains 2*r-1 numbers.
		

Crossrefs

Cf. A081344, A209293, A209279, A209278, A185180; table T(n,k) contains: in rows A000982, A097063; in columns A000217, A000124, A000096, A152948, A034856, A152950, A055998, A000982, A097063.

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)
    m1=int((i+j)/2)+int(i/2)*(-1)**(2*i+j-1)
    m2=int((i+j+1)/2)+int(i/2)*(-1)**(2*i+j-2)
    result=(m1+m2-1)*(m1+m2-2)/2+m1

Formula

As table
T(n,k) = n*n/2+4*(floor((k-1)/2)+1)*n+ceiling((k-1)^2/2), n,k > 0.
As linear sequence
a(n)= (m1+m2-1)*(m1+m2-2)/2+m1, where
m1=floor((i+j)/2) + floor(i/2)*(-1)^(2*i+j-1), m2=int((i+j+1)/2)+int(i/2)*(-1)^(2*i+j-2),
where i=(t mod 2)*min(t; n-(t-1)^2) + (t+1 mod 2)*min(t; t^2-n+1), j=(t mod 2)*min(t; t^2-n+1) + (t+1 mod 2)*min(t; n-(t-1)^2), t=floor(sqrt(n-1))+1.
Showing 1-5 of 5 results.