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.

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.

A226005 Lexicographically earliest sequence such that (a(n), a(n+1)) runs through all the pairs of nonnegative integers exactly once, with the constraint that a(n)=0 iff n is a square.

Original entry on oeis.org

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

Views

Author

Paul Tek, May 22 2013

Keywords

Comments

a(k^2-2) = a(k^2-1) = k-1 for any k > 1.
If (a(k), a(k+1)) = (x,y), then max(x,y)^2 <= k < (max(x,y)+1)^2.

Examples

			a(0)=0.
a(1)=0.
a(2)>0; (0,1) has not yet been visited, hence a(2)=1.
a(3)>0; (1,1) has not yet been visited, hence a(3)=1.
a(4)=0.
a(5)>0; (0,1) has been visited, but (0,2) has not, hence a(5)=2.
a(6)>0; (2,1) has not yet been visited, hence a(6)=1.
a(7)>0; (1,1) has been visited, but (1,2) has not, hence a(7)=2.
a(8)>0; (2,1) has been visited, but (2,2) has not, hence a(8)=2.
a(9)=0.
etc.
		

Crossrefs

Programs

  • Perl
    my @a = (0);
    foreach my $k (1..10) {
        push @a => 0, ( map { ($k, $_) } 1..$k-1 ), $k, $k;
    }

Formula

a(n) = ([sqrt n]^2 + [(n-[sqrt n]^2)/2])/2 - (-1)^(n-[sqrt n]^2)*([sqrt n]^2-[(n-[sqrt n]^2)/2])/2, where [] represents the floor function. - David Adam, Nov 09 2017

A332104 Triangle read by rows in which row n >= 0 lists numbers from 0 to n starting at floor(n/2) and using alternatively larger respectively smaller numbers than the values used so far.

Original entry on oeis.org

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

Views

Author

M. F. Hasler, May 30 2020

Keywords

Comments

The idea is to cover the range 0..n starting from the center and approaching the limiting values in the most symmetric way, using the smaller value in case of a tie, which leads to each row ending in (the first occurrence of) n.
Contains any sequence of nonnegative integers as a subsequence.

Examples

			The table starts:
Row 0:  0;
Row 1:  0, 1;
Row 2:  1, 0, 2;
Row 3:  1, 2, 0, 3;
Row 4:  2, 1, 3, 0, 4;
Row 5:  2, 3, 1, 4, 0, 5;
Row 5:  3, 2, 4, 1, 5, 0, 6;
Row 6:  3, 4, 2, 5, 1, 6, 0, 7;
Row 7:  4, 3, 5, 2, 6, 1, 7, 0, 8;
Row 8:  4, 5, 3, 6, 2, 7, 1, 8, 0, 9;
Row 9:  5, 4, 6, 3, 7, 2, 8, 1, 9, 0, 10;
Row 10: 5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 0, 11; ...
Column 1 is floor(n/2) = A004526(n).
The "diagonal" (last element of each row) are the nonnegative integers A001477.
The first subdiagonal is the zero sequence A000004.
The second subdiagonal is the set of positive integers A000027.
The third subdiagonal is "all ones" sequence A000012.
And so on: in alternance, every other subdiagonal is the set of integers >= k, resp., k times the all ones sequence.
		

Crossrefs

Cf. A196199 (concatenate [-n .. n] for n=0, 1, 2...).
Cf. |A128180| = A209279 (based on a very similar idea with positive integers instead).

Programs

  • Mathematica
    Table[Floor[(n + (-1)^(n - k)*k)/2], {n, 0, 12}, {k, 0, n}] // Flatten (* Michael De Vlieger, Jul 03 2020 *)
  • PARI
    row(n)={ my(m=n\2, M=m, r=[m]); while(#r <= n, r=concat(r, if( n-M > m, M+=1, m-=1))); r}
    
  • PARI
    T(n,k)=(n+(-1)^(n-k)*k)\2

Formula

If columns are indexed starting from 0:
T(n,0) = floor(n/2) = A004526(n).
T(n,n-2*k) = n-k, for k >= 0.
T(n,n-2*k-1) = k, for k >= 0.
T(n,k) = floor((n+(-1)^(n-k)*k)/2) = (n+k)/2 if n+k even, otherwise floor((n-k)/2).
a(n) = |A128180(n)| - 1.

A339132 Milk shuffle of the binary representation of n.

Original entry on oeis.org

0, 1, 2, 3, 2, 3, 6, 7, 2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 18, 19, 22, 23, 10, 11, 14, 15, 26, 27, 30, 31, 2, 3, 6, 7, 18, 19, 22, 23, 34, 35, 38, 39, 50, 51, 54, 55, 10, 11, 14, 15, 26, 27, 30, 31, 42, 43, 46, 47, 58, 59, 62, 63, 2, 3, 6, 7, 18, 19, 22, 23
Offset: 0

Views

Author

Sander G. Huisman, Nov 24 2020

Keywords

Examples

			For n = 19 we take the binary representation without leading zeros: 10011.
We now shuffle the binary digits around according to A209279, which can be interpreted as a so-called milk shuffle.
For five digits the n-th digits gets moved around as follows: 1,2,3,4,5 => 3,2,4,1,5.
This reshuffling can be thought of taking the middle number, and then alternatingly taking digits from the left and then the right until all digits are taken.
We now apply this reshuffling to our binary digits of 19: 00111.
This is now reinterpreted into a decimal number: 7.
		

Crossrefs

Cf. A330090 (shuffle bits low to high).
Cf. A209279 (1-based shuffle), A332104 (0-based shuffle).

Programs

  • Mathematica
    milk[list_]:=Table[list[[{i,-i}]],{i,Length[list]/2}]//milkPost[#,list]&//Reverse//Flatten
    milkPost[x_,list_]:=x/;EvenQ[Length[list]]
    milkPost[x_,list_]:=Join[x,{list[[(Length[list]+1)/2]]}]
    Table[FromDigits[milk@IntegerDigits[i,2],2],{i,0,500}]
    (*OR*)
    Table[FromDigits[ResourceFunction["Shuffle"][IntegerDigits[i,2],"Milk"],2], {i,0,500}]
Showing 1-5 of 5 results.